请问,我做的任务是从Ftp下载东西保存到当地,但是我想让提示个保存路径的框,改怎么做?求指教~C#+.net

2025-01-05 11:41:36
推荐回答(2个)
回答(1):

private void FileDownLoad(string filename)
{
string destFileName = filename;
//destFileName = Server.MapPath("./") + destFileName;
destFileName = Server.UrlDecode(destFileName);
if (File.Exists(destFileName))
{
FileInfo fi = new FileInfo(filename);
Response.Clear();
Response.ClearHeaders();
Response.Buffer = true;
Response.Charset = "GB2312";
//添加头信息,为 "文件下载/另存为 "对话框指定默认文件名
Response.AppendHeader("Content-Disposition", "attachment;filename="
+ HttpUtility.UrlEncode(Path.GetFileName(destFileName),
System.Text.Encoding.UTF8));
Response.AppendHeader("Content-Length", fi.Length.ToString());
Response.ContentType = "text/plain";
Response.Filter.Close();
Response.WriteFile(destFileName);
Response.Flush();
Response.End();
}
else
{
Response.Write("");
}
}

回答(2):

.net直接有一个控件。FileUpload拉到项目上,然后1楼的代码很完善了,可以照做