在Asp.net里可能会用到让客户下载文件的操作: /// <summary> /// 客户下载文件 /// </summary> /// <param name="fileName">服务器源文件物理地址</param> private void DownloadFile( string fileName) ... { string saveFile = System.IO.Path.GetFileName(fileName); string extName = System.IO.Path.GetExtension(fileName); string defaultType = "application/unknown"; RegistryKey rootKey, extKey; string contentType; try ...{ rootKey = Registry.ClassesRoot; extKey = rootKey.OpenSubKey(extName); contentType = extKey.GetValue("Content Type", defaultType).ToString(); } catch ...{ contentType = defaultType; } Response.Clear(); Response.Buffer = true; Response.AppendHeader("Content-Disposition", "attachment;filename=" + saveFile); Response.ContentType = contentType; Response.WriteFile(fileName); Response.Flush(); Response.Close(); } 方法来源于这个地址:http://www.itlearner.com/article/2005/2375.shtml 觉得文章的作者写的很不错,为了记录这个方法特在些做个备份以便以后查阅!