azure - 微软 azure : Not Able To Copy Azure Cloud File To Another Directory

标签 azure azure-storage azure-storage-files azure-files

我正在尝试将云文件从一个目录复制到同一文件共享帐户中的另一个目录,但遇到问题。

代码:

下面是我正在使用的代码,以下文章(https://learn.microsoft.com/en-us/azure/storage/files/storage-dotnet-how-to-use-files#copy-files)

public bool ArchiveTheFile(string filename)
    {
        bool fileCopied = false;
        try
        {
            var fileshare = ResolveCloudFileShare();
            if (fileshare.Exists())
            {
                CloudFileDirectory rootDir = fileshare.GetRootDirectoryReference();
                CloudFileDirectory dirSource = rootDir.GetDirectoryReference(ConfigurationManager.AppSettings["Azure.Storage.FileShare.Source"]);
                CloudFileDirectory dirArchive = rootDir.GetDirectoryReference(ConfigurationManager.AppSettings["Azure.Storage.FileShare.Destination"]);

                // Ensure that the directory exists.
                if (dirSource.Exists())
                {
                    // Get a reference to the file we created previously.
                    CloudFile sourceFile = dirSource.GetFileReference(filename);

                    // Ensure that the file exists.
                    if (sourceFile.Exists())
                    {
                        // Ensure that the directory exists.
                        if (dirArchive.Exists())
                        {
                            // Get a reference to the destination file.
                            CloudFile destFile = dirArchive.GetFileReference(filename);
                            destFile.StartCopy(sourceFile);fileCopied =true;
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
        }
        return fileCopied ;
    }

以下是错误:

无法使用CloudFile类的StartCopy()方法

<强>1。错误截图:

enter image description here

GetFileReference() 返回的对象没有 StartCopy() 方法:

enter image description here

<强>2。错误消息:

“CloudFile”不包含“StartCopy”的定义,并且找不到接受“CloudFile”类型的第一个参数的扩展方法“StartCopy”(您是否缺少 using 指令或程序集引用?

请注意: 我已经在使用以下两个程序集引用:

使用 Microsoft.WindowsAzure.Storage;

使用 Microsoft.WindowsAzure.Storage.File;

最佳答案

将您的 Microsoft.WindowsAzure.Storage 软件包更新到最新版本或至少 5.0.2。在版本 5.0.2 之前,不支持 CloudFileStartCopy

关于azure - 微软 azure : Not Able To Copy Azure Cloud File To Another Directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50325196/

相关文章:

azure - 如何将 Azure Active Directory (WAAD) 连接到 Windows Azure 访问控制服务 (ACS)?

Azure 存储 CloudBlockBlob.PutBlockAsync() HTTP header 之一的值格式不正确。

terraform - 是否可以使用 terraform 将文件上传到 Azure Share?

c# - 使用 C# 代码在第 2 代 Azure 存储帐户之间复制大文件

azure - 从逻辑应用对 azure 文件服务中的新文件执行操作

c# - 使用 Azure WebJobs/Azure Functions 在服务队列上安排消息?

azure - Azure 中的 Windows 工作流

Azure 示例应用程序

Azure:如何以编程方式创建事件订阅

sql-server - 无法从 ubuntu 连接到 azure sql server