azure - MS Azure:无法将 Azure 云文件复制到另一个目录
问题描述
我正在尝试在同一个文件共享帐户中将云文件从一个目录复制到另一个目录,但面临问题。
代码:
以下是我正在使用的代码,以下文章(https://docs.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.错误截图:
GetFileReference() 返回的对象没有 StartCopy() 方法:
2.错误信息:
“CloudFile”不包含“StartCopy”的定义,并且找不到接受“CloudFile”类型的第一个参数的扩展方法“StartCopy”(您是否缺少 using 指令或程序集引用?
请注意:我已经在使用以下两个程序集参考:
使用 Microsoft.WindowsAzure.Storage;
使用 Microsoft.WindowsAzure.Storage.File;
解决方案
将您的Microsoft.WindowsAzure.Storage
软件包更新到最新版本或至少 5.0.2。直到版本 5.0.2 才支持StartCopy
for 。CloudFile
推荐阅读
- git - 基于 git 哈希最小化 Jenkins 构建的数量
- python-3.x - 如何使用切片或其他方法在 pandas 中分配列表值?
- java - 如何制作一个递归方法,它采用 List 类型,其中输出是不同的 List?
- javascript - 了解 Papaparse
- javascript - 从js中另一个对象的值创建新对象
- r - 当我包含新的固定效果时,MEEM 中的错误
- r - 防止 rm_stopwords 函数创建列表
- html - CSS / SCSS - 访问具有未知子类型的子元素的子元素
- python - 使用带有 3 通道输入的 HoughCircles 时出错
- node.js - 傀儡师。Page.evluate() 没有运行或没有得到结果