1

我正在创建一个网站,可用于将文件上传到云端并下载相同的文件。当我在本地运行时尝试下载文件时,一切正常。将文件发布到 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;
   }`
4

1 回答 1

0

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

于 2013-03-24T19:08:48.743 回答