C# 下载文件
public bool downloadLfpFile(string filePath, string callback)//参数:下载文件全路径,回调函数
{
WebClient client = new WebClient();
string url = filePath;
Stream strm = client.OpenRead(filePath);
string filename = url.Substring(url.LastIndexOf('/') + 1);
int count = 0;
byte[] buffer = new byte[4096];
FileStream fs = new FileStream(lfpDataDirectory + "//" + filename, FileMode.Create);
while ((count = strm.Read(buffer, 0, buffer.Length)) > 0)
{
fs.Write(buffer, 0, count);
}
fs.Close();
strm.Close();
strm.Dispose();
fs.Dispose();
mainWindow.Browser.ExecuteScriptAsync(callback + "()");
System.Diagnostics.Process.Start("explorer.exe", lfpDataDirectory);
return true;
}