到 Azure c# 的简单文件传输
Simple File Transfer to Azure c#
假设我在 Azure 中的一个名为 "mystorage" 的存储帐户中创建了一个名为 "myshare" 的文件共享,什么会导致下面的代码在 UploadFromFile 上给出此错误消息?
"The specified resource does not exist. RequestId:longstring Time:currenttime"
上传这个我缺少什么?
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());
}
}
}
修改命令
CloudFileShare fs = new CloudFileShare(new Uri(directorystring));
和
CloudFileShare fs = fc.GetShareReference("share name");
假设我在 Azure 中的一个名为 "mystorage" 的存储帐户中创建了一个名为 "myshare" 的文件共享,什么会导致下面的代码在 UploadFromFile 上给出此错误消息?
"The specified resource does not exist. RequestId:longstring Time:currenttime"
上传这个我缺少什么?
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());
}
}
}
修改命令
CloudFileShare fs = new CloudFileShare(new Uri(directorystring));
和
CloudFileShare fs = fc.GetShareReference("share name");