HttpWebRequest myHttpWebRequest =(HttpWebRequest)WebRequest.Create(“http://localhost:51659/jobpoint3.0/Default4.aspx”);
WebClient客户端=新WebClient();
string filename = @“C:/ Users / leema /”+ txtsave.Text;
client.DownloadFile(“http://localhost:51659/jobpoint3.0/Default4.aspx”,@“C:/ Users / leema /”+ txtsave.Text);
// HttpResponseWriteFile(文件名);
HttpWebResponse myHttpWebResponse =(HttpWebResponse)myHttpWebRequest.GetResponse();
myHttpWebResponse.Close();
这里我正在获取本地路径..如何为任何用户获取用户的桌面路径?
答案 0 :(得分:0)
代码是
Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)
因此您的第3行将被修改为
string filename = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), txtsave.Text);