服务器未指向文件夹

时间:2012-10-04 08:56:03

标签: asp.net

我在服务器上有一个网站。它有一个按钮,可以触发从该服务器下载文件(.zip / .doc)。 但它并没有指向那个文件夹/文件。如何解决这个问题??

在此特定文件中失败...

public static bool ResponseFile(HttpRequest _Request, HttpResponse _Response, string _fileName, string _fullPath, long _speed){
FileStream myFile = new FileStream(_fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
}

1 个答案:

答案 0 :(得分:0)

我没有尝试过您的代码,但这似乎对我有用。你可以让其他动态。

string FileName = "test.zip";
string PathFile = "C:\project\download\test.zip";
var fileInfo = new System.IO.FileInfo(PathFile);
Response.ContentType = "application/zip";
Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", FileName));
Response.AddHeader("Content-Length", fileInfo.Length.ToString());
Response.WriteFile(PathFile);
Response.End();