0

我是网络编程的新手,很抱歉这样的问题。我使用WebClient.DownloadFile(string fileAdress, string fileName)方法下载文件。我fileName来自fileAdress(ie www.somelink.com/file.txt => file.txt) 。现在,我需要获取该文件的完整路径。如果它是桌面应用程序,我会以某种方式找到它。但现在,我不知道情况。

4

1 回答 1

0

The downloaded file should be saved in your current directory. i.e., in

Directory.GetCurrentDirectory()

Example:

using System.IO;
using System.Net;

var uri = new Uri("http://example.com/somefile.txt");
string filename = "somefile.txt";

new WebClient().DownloadFile(uri, filename);
string filePath = Path.Combine(Directory.GetCurrentDirectory(), filename);
于 2013-01-24T10:21:54.280 回答