Я пытаюсь скопировать облачный файл из одного каталога в другой в рамках той же учетной записи общего доступа к файлам, но столкнулся с проблемой.
Код:
Ниже приведен код, который я использую, следующая статья (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 ;
}
Ниже приведена ошибка:
Невозможно использовать StartCopy () метод CloudFile класс
1. Скриншот ошибки:
![enter image description here](https://i.stack.imgur.com/KVwCr.png)
Объект, возвращаемый методом GetFileReference (), не имеет метода StartCopy ():
![enter image description here](https://i.stack.imgur.com/9UaNs.png)
2. Сообщение об ошибке:
«CloudFile» не содержит определения для «StartCopy», и невозможно найти метод расширения «StartCopy», принимающий первый аргумент типа «CloudFile» (вы пропустили директиву using или ссылку на сборку?
Обратите внимание:
Я уже использую ниже две ссылки на сборку:
с использованием Microsoft.WindowsAzure.Storage;
с использованием Microsoft.WindowsAzure.Storage.File;