我正在尝试使用xamarin通过android从我的服务器下载文件,我没有发现任何错误,但我没有找到任何应该在哪里的文件。
我使用的代码是:
System.Net.WebClient Client = new System.Net.WebClient();
Console.WriteLine("Start downloading...");
try
{
var documentsFolder = System.Environment.GetFolderPath (System.Environment.SpecialFolder.MyDocuments);
if(!File.Exists(documentsFolder))
Directory.CreateDirectory(documentsFolder);
var fileNameAndPath = Path.Combine (documentsFolder, "tmpfile");
Client.DownloadFile(new Uri(url), fileNameAndPath);
}
catch(System.Exception e)
{
System.Diagnostics.Debug.WriteLine(e.Message);
while(e.InnerException!=null)
{
e=e.InnerException;
System.Diagnostics.Debug.WriteLine(e.Message);
}
}
Console.WriteLine("...end downloading");
没有捕获错误,但没有下载文件,我尝试了几种特殊路径,但似乎都不起作用。有人能帮我吗?