Asp.net mvc 如何获取使用WebClient.DownloadFile()下载的文件路径?
我是网络编程新手,很抱歉提出这样的问题。我使用Asp.net mvc 如何获取使用WebClient.DownloadFile()下载的文件路径?,asp.net-mvc,path,webclient,Asp.net Mvc,Path,Webclient,我是网络编程新手,很抱歉提出这样的问题。我使用WebClient.DownloadFile(stringfileaddress,stringfilename)方法下载文件。我从fileaddress(即www.somelink.com/file.txt=>file.txt)获得fileName。现在,我需要得到那个文件的完整路径。如果它是桌面应用程序,不知何故我会找到它。但现在,我不知道这种情况。下载的文件应该保存在您当前的目录中。i、 例如,在 Directory.GetCurrentDire
WebClient.DownloadFile(stringfileaddress,stringfilename)
方法下载文件。我从fileaddress
(即www.somelink.com/file.txt=>file.txt)获得fileName
。现在,我需要得到那个文件的完整路径。如果它是桌面应用程序,不知何故我会找到它。但现在,我不知道这种情况。下载的文件应该保存在您当前的目录中。i、 例如,在
Directory.GetCurrentDirectory()
例如:
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);