private string NewFile_Service(string reporter, string productSN, string docType, string fileName, string filePath, string Ext, string Time) { string ret = "ERROR"; deviceInfo devInfo = new deviceInfo(); Service1SoapClient test1 = new Service1SoapClient(); string productType = devInfo.GetProductType(productSN); string filePathAll = filePath + fileName; using (FileStream fileStream = new FileStream(filePathAll, FileMode.Open, FileAccess.Read, FileShare.Read)) { // 读取文件的 byte[] byte[] bytes = new byte[fileStream.Length]; fileStream.Read(bytes, 0, bytes.Length); fileStream.Close(); /* * // 把 byte[] 转换成 Stream * Stream stream = new MemoryStream(bytes); * byte[] bytes = new byte[stream.Length]; * stream.Read(bytes, 0, bytes.Length); * // 设置当前流的位置为流的开始 * stream.Seek(0, SeekOrigin.Begin); */ try { ret = test1.CollectDevice_MES_Doc_New(reporter, deviceInfo.deviceCode, productType, productSN, docType, deviceInfo.folderId, fileName, bytes, Ext, Time); } catch (Exception ex) { throw new Exception(ex.Message); } } return(ret); }