zoukankan      html  css  js  c++  java
  • 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;
    }

  • 相关阅读:
    CentOS
    Docker
    Chart的简单使用
    DataGridView中间插入数据行
    获取每个月的固定的第n个星期几
    设置只能开启一个程序实例
    DataContext与实体类
    Attribute
    Delegate
    Event
  • 原文地址:https://www.cnblogs.com/sagerking/p/15594152.html
Copyright © 2011-2022 走看看