gpt4 book ai didi

c# - 简单文件传输到 Azure c#

转载 作者:行者123 更新时间:2023-12-03 01:39:57 28 4
gpt4 key购买 nike

假设我在 Azure 中名为“mystorage”的存储帐户中创建了一个名为“myshare”的文件共享,什么会导致下面的代码在 UploadFromFile 上给出此错误消息?

“指定的资源不存在。RequestId:longstring 时间:当前时间”

我缺少什么才能上传此内容?

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");

关于c# - 简单文件传输到 Azure c#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54728520/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com