【问题标题】:Programmatically (.NET) renaming an Azure File or Directory using File (not Blob) Storage使用文件(不是 Blob)存储以编程方式 (.NET) 重命名 Azure 文件或目录
【发布时间】:2015-03-02 17:39:48
【问题描述】:

我读过使用 Azure file 存储创建的文件和目录可以通过编程方式重命名,但找不到使用 .NET Microsoft.WindowsAzure.Storage 程序集(我正在使用v4.3.)。我知道 blob 不能重命名,但使用文件存储的文件应该可以。作为参考,我在下面包含了代码 sn-p。非常感谢任何帮助。

CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse("mycredentials");

CloudFileClient fileClient = cloudStorageAccount.CreateCloudFileClient();

CloudFileShare fileShare = fileClient.GetShareReference("myfileshare");

fileShare.CreateIfNotExists();

CloudFileDirectory rootDir = fileShare.GetRootDirectoryReference();

CloudFileDirectory directory = rootDir.GetDirectoryReference("mydirectory");

// The Name property of directory is read-only, and can't find a Rename method

【问题讨论】:

    标签: .net azure


    【解决方案1】:

    到目前为止,Azure 上不支持重命名操作,这可能是有原因的,但是,另一种方法是使用新名称创建副本并删除旧名称。甚至 amazon s3 也不支持重命名。原因可能是索引和缓存在多个级别上完成,无法轻易重命名,因此它们没有包含在核心功能中。

    【讨论】:

    • 谢谢。这样做的问题之一是使用文件存储重命名目录的开销。我需要删除并重新创建要重命名的目录的目录层次结构中的每个文件和目录,这可能是许多文件和子目录。到目前为止,Azure 还没有想出有效的方法来实现这一点,这似乎有点荒谬。
    猜你喜欢
    • 2018-11-07
    • 1970-01-01
    • 2013-09-29
    • 2013-04-13
    • 2020-10-24
    • 2019-11-27
    • 2020-03-27
    • 1970-01-01
    • 2015-07-13
    相关资源
    最近更新 更多