假设我在一个名为“ mystorage”的存储帐户中在Azure中创建了一个名为“ myshare”的文件共享,这将导致以下代码在UploadFromFile上给出此错误消息吗?
“指定的资源不存在。RequestId:长字符串时间:当前时间”
要上传此文件我想念什么?
static string connstring = "connection string copied from Azure access keys"
static string directorystring = "data being used is url in properties of file share in Azure, for this example it would be https://mystorage.file.core.windows.net/myshare"
DialogResult a = openFileDialog.ShowDialog();
string[] filenames = openFileDialog.FileNames;
foreach(string filename in filenames)
{
string filenameonly = Path.GetFileName(filename);
CloudStorageAccount sa = CloudStorageAccount.Parse(connstring);
CloudFileClient fc = sa.CreateCloudFileClient();
CloudFileShare fs = new CloudFileShare(new Uri(directorystring));
CloudFileDirectory fd = fs.GetRootDirectoryReference();
CloudFile f = fd.GetFileReference(filenameonly);
try
{
f.UploadFromFile(filename);
}
catch (StorageException excep)
{
MessageBox.Show(excep.RequestInformation.ExtendedErrorInformation.ErrorMessage.ToString());
}
}
}
答案 0 :(得分:2)
修改命令
CloudFileShare fs = new CloudFileShare(new Uri(directorystring));
使用
CloudFileShare fs = fc.GetShareReference("share name");