gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 06:46:21 25 4
gpt4 key购买 nike

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

代码:

下面是我正在使用的代码,以下文章(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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com