MS Azure: не удается скопировать файл облака Azure в другой каталог - PullRequest
0 голосов
/ 14 мая 2018

Я пытаюсь скопировать облачный файл из одного каталога в другой в рамках той же учетной записи общего доступа к файлам, но столкнулся с проблемой.

Код:

Ниже приведен код, который я использую, следующая статья (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

Объект, возвращаемый методом GetFileReference (), не имеет метода StartCopy ():

enter image description here

2. Сообщение об ошибке:

«CloudFile» не содержит определения для «StartCopy», и невозможно найти метод расширения «StartCopy», принимающий первый аргумент типа «CloudFile» (вы пропустили директиву using или ссылку на сборку?

Обратите внимание: Я уже использую ниже две ссылки на сборку:

с использованием Microsoft.WindowsAzure.Storage;

с использованием Microsoft.WindowsAzure.Storage.File;

1 Ответ

0 голосов
/ 15 мая 2018

Обновите свой пакет Microsoft.WindowsAzure.Storage до последней версии или не ниже 5.0.2. StartCopy для CloudFile не поддерживается до версии 5.0.2.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...