2012-05-08 33 views
2

我已经写了两个方法,例如FileUpLoad()和FileDownLoad()来上载和下载我的本地系统中的单个文件。如何在IIS中下载文件?

void FileUpLoad() 
{ 
    string hfBrowsePath = fuplGridDocs.PostedFile.FileName; //fuplGridDocs is a fileupload control 
    if (hfBrowsePath != string.Empty) 
    { 
     string destfile = string.Empty;    
     string FilePath = Path.Combine(@"E:\Documents\");    
     FileInfo FP = new FileInfo(hfBrowsePath); 
     hfFileNameAutoGen.Value = PONumber + FP.Extension; 
     destfile = FilePath + hfFileNameAutoGen.Value; //hfFileNameAutoGen is a hidden field 
     fuplGridDocs.PostedFile.SaveAs(destfile); 
    } 
} 

void FileDownLoad(LinkButton lnkFileName) 
{ 
    string filename = lnkFileName.Text; 
    string FilePath = Path.Combine(@"E:\Documents", filename); 
    fuplGridDocs.SaveAs(FilePath); 
    FileInfo fileToDownLoad = new FileInfo(FilePath); 

    if (fileToDownLoad.Exists) 
    { 
     Process.Start(fileToDownLoad.FullName); 
    } 
    else 
    { 
     lblMessage.Text = "File Not Saved!"; 
     return; 
    } 
} 

虽然在IIS托管之前运行的应用程序,我可以将文件上传到所需位置,也可以检索从保存的位置的文件。但是在将它发布到本地主机后,我只能上传一个文件。我无法下载保存的文件。也没有例外。上传的文件保存在所需的位置。我不知道为什么它不检索文件?为什么我不能在IIS下载文件?我在互联网上搜索了很多,但找不到解决方案。如何解决这个问题?我正在使用Windows XP和IIS 5.1版本。

回答

0

另一种选择是将您的通配符添加到IIS MIME类型