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 }
时间: 2024-10-02 09:33:56