zoukankan      html  css  js  c++  java
  • C#利用WebService接口下载文件

     1             WebTest.RtTfSimDataInterface test = new WebTest.RtTfSimDataInterface();
     2             //string strBasic = test.GetTfBasicDataInfo("admin", "123", "11", true);
     3             string strRealTime = test.GetTfRealTimeDataInfo("admin", "11", "11", true);
     4             //string strjson = HttpUtility.UrlDecode(HttpUtility.UrlEncode(str));
     5 
     6             WebTest.xsdDwgInfo dd = test.GetTfDwgBinaryInfo("admin", "admin", "1", 0);
     7 
     8             /////////////////////////////////////////////////////////////////////////////
     9             int nReadSize = dd.mnReadSize;//读取文件大小
    10             sbyte[] mySByte = new sbyte[nReadSize];
    11             mySByte = dd.mpBuffer;
    12             bool bEof = dd.mbEof;
    13             string strFileName = dd.mstrFileName;//文件名称
    14             string strDwg_UpdateTime = dd.mstrDwgUpdateTime;//文件最后更新时间
    15             //写数据
    16 
    17             byte[] arr = new byte[nReadSize];
    18             Buffer.BlockCopy(mySByte, 0, arr, 0, nReadSize);//sbyte[]转byte[]
    19 
    20             if (!File.Exists("E:\a.dwg"))
    21             {
    22                 FileStream FsCreate = new FileStream("E:\a.dwg", FileMode.Create);
    23                 FsCreate.Close();
    24             }
    25             FileStream fs = new FileStream("E:\a.dwg", FileMode.Append, FileAccess.Write);
    26             fs.Write(arr, 0, nReadSize);//写入byte[]
    27             fs.Close();
    28 
    29             int nPosition = dd.mnReadSize;//读取文件位置
    30 
    31             while (!bEof)//文件未下载完成,继续下载
    32             {
    33                 dd = test.GetTfDwgBinaryInfo("admin", "admin", "1", nPosition);
    34                 nPosition += dd.mnReadSize;
    35                 bEof = dd.mbEof;
    36                 nReadSize = dd.mnReadSize;
    37                 sbyte[] sbyteTmp = new sbyte[nReadSize];
    38                 sbyteTmp = dd.mpBuffer;
    39 
    40                 byte[] arrTmp = new byte[sbyteTmp.Length];
    41                 Buffer.BlockCopy(sbyteTmp, 0, arrTmp, 0, sbyteTmp.Length);
    42 
    43                 if (!File.Exists("E:\a.dwg"))
    44                 {
    45                     FileStream FsCreate = new FileStream("E:\a.dwg", FileMode.Create);
    46                     FsCreate.Close();
    47                 } FileStream fsTmp = new FileStream("E:\a.dwg", FileMode.Append, FileAccess.Write);
    48                 fsTmp.Write(arrTmp, 0, nReadSize);
    49                 fsTmp.Close();
    50             }
  • 相关阅读:
    CSS实现字母全大写
    人生职业规划与自身设想
    关于人生的一些想法,和淘客SEO的思想。
    保持积极向上的心态去把傻逼的坚持换成牛逼的结果
    SEO站群随想,及自我的认知和想法
    我是SEOer,我为自己代言
    打印出 html结构中的ul li
    js数据类型转换
    js object类型转换 内存泄漏 垃圾回收机制
    页面重置样式reset.css
  • 原文地址:https://www.cnblogs.com/lpxblog/p/4949138.html
Copyright © 2011-2022 走看看