以编程方式(.NET)使用文件(而非Blob)存储重命名Azure文件或目录 [英] Programmatically (.NET) renaming an Azure File or Directory using File (not Blob) Storage

查看:54
本文介绍了以编程方式(.NET)使用文件(而非Blob)存储重命名Azure文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读到可以使用编程方式重命名使用Azure file 存储创建的文件和目录,但是无法找到使用.NET Microsoft.WindowsAzure.Storage程序集进行重命名的方法(我正在使用v4.3.).我知道blob无法重命名,但是使用文件存储的文件应该可以重命名.供参考,我在下面包括了代码片段.任何帮助都将不胜感激.

I've read that files and directories created using Azure file storage can be renamed programmatically, but cannot find a way to do that using the .NET Microsoft.WindowsAzure.Storage assembly (I am using v4.3.). I know that blobs cannot be renamed, but files using file storage supposedly can. For reference I'm including the code snippet below. Any help greatly appreciated.

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

推荐答案

直到现在,Azure上不支持重命名操作,并且可能有其背后的原因,但是,替代方法是使用新名称创建副本并删除旧名称.甚至Amazon S3也不支持重命名.原因可能是在多个级别上完成了索引和缓存,这些索引和缓存无法轻松重命名,因此没有被包含为核心功能.

Till date, there is no rename operation supported on Azure and there might be reasons behind that, however, the alternative is to create a copy with new name and deleting old name. Even amazon s3 does not support renaming. The reason could be indexing and caching done at many levels, which cannot be renamed easily so they have not included as a core feature.

这篇关于以编程方式(.NET)使用文件(而非Blob)存储重命名Azure文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆