Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从blob下载在本地工作,但在发布后不工作_C#_Visual Studio_Download_Cloud_Azure Storage Blobs - Fatal编程技术网

C# 从blob下载在本地工作,但在发布后不工作

C# 从blob下载在本地工作,但在发布后不工作,c#,visual-studio,download,cloud,azure-storage-blobs,C#,Visual Studio,Download,Cloud,Azure Storage Blobs,我正在创建一个网站,可以将文件上传到云端并下载。当我尝试下载本地运行的文件时,一切正常。将文件发布到Azure后,状态显示该文件已下载,但该文件在下载位置不可用。 提前谢谢 //My Download Code ` protected void OnDownloadImage(object sender, CommandEventArgs e) { var account = CloudStorageAccount.FromConfigurationSetting("DataCon

我正在创建一个网站,可以将文件上传到云端并下载。当我尝试下载本地运行的文件时,一切正常。将文件发布到Azure后,状态显示该文件已下载,但该文件在下载位置不可用。 提前谢谢

//My Download Code
` protected void OnDownloadImage(object sender, CommandEventArgs e)
  {
     var account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
     var client = account.CreateCloudBlobClient();
     CloudBlobContainer blobContainer = client.GetContainerReference("Gallery");
     var blobUri = (string)e.CommandArgument;
     var srcBlob = this.GetContainer().GetBlobReference(blobUri);
     srcBlob.FetchAttributes(new BlobRequestOptions { BlobListingDetails = BlobListingDetails.Metadata });
     var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory));
     path = path + @"\AJStorage";
     Directory.CreateDirectory(path);
     path = path + "\\" + Path.GetFileName(srcBlob.Metadata["FileName"]);
     srcBlob.DownloadToFile(path);
     this.status.Text = "File Download Successful. File Location : " + path;
   }`

我想我理解这个问题。您正试图将文件下载到桌面上,但这将是web服务器的桌面(您几乎肯定没有权限),而不是用户的桌面(这可能是您所追求的)。如果是,你不能直接这么做。而是尝试将文件发送到HTTP响应流。(我使用的DownloadToStream是Microsoft.WindowsAzure.StorageClient的一部分)

@Jothishwar RS,请在您的问题中重新格式化您的代码,并进行更多解释以获得帮助。我认为问题在于我设置了将文件保存到本地光盘的路径。错误可能是因为服务器没有创建文件的适当权限。我想知道如何修改我的代码,以便允许从服务器下载文件,同时在本地工作正常。感谢youthnx Andih的回复。你说的就是我网站上的错误。现在我清除了我的错误,并设置为wrk:)thnx很多我也参考了下面的博客。酷-您引用的代码使用DownloadToStream,这几乎与我所做的完全一样:-)