【问题标题】:Azure File Share Create DirectoryAzure 文件共享创建目录
【发布时间】:2017-12-14 20:36:46
【问题描述】:

我正在审查 Azure 文件共享服务。我想确定创建目录需要什么。对于此类活动没有明确的配置 - 所以我只是尝试运行一个测试场景来创建一个目录。该目录将在根目录下创建。附上代码:

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connect);
CloudFileClient fileClient = storageAccount.CreateCloudFileClient();

CloudFileShare fileShare = fileClient.GetShareReference("fileaccess");
if (fileShare.Exists())
{
   CloudFileDirectory rootDirectory = fileShare.GetRootDirectoryReference();
   if (rootDirectory.Exists())
   {                        
     CloudFileDirectory customDirect = 
         rootDirectory.GetDirectoryReference("TEST");
     if (!customDirect.Exists())
     {
        rootDirectory.Create();
     }
   }
}

结果如下错误:

远程服务器返回错误:(405) Method Not Allowed。

我认为这是 Azure 上的配置 - 但我看不到 Azure 上允许此操作的位置。

彼得

【问题讨论】:

    标签: azure azure-storage-files


    【解决方案1】:

    远程服务器返回错误:(405) Method Not Allowed

    根本原因:

    我确定在代码行rootDirectory.Create(); 中发生了 405 错误。 Azure 不允许我们创建根目录,因此 Azure 服务器不接受它。

    解决方案:

    根据您的代码逻辑,您似乎要创建customDirect,所以请将代码更改如下:

    if (!customDirect.Exists())
    {
       customDirect.Create();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-18
      • 2016-07-03
      • 1970-01-01
      • 2011-02-04
      • 2014-10-12
      相关资源
      最近更新 更多