zoukankan      html  css  js  c++  java
  • WCF 传输 Byte[] 部分代码 无觉

    //客户端调用
                using (FileStream fs = new FileStream(sourceFilePath, FileMode.Open))
                {
                    byte[] bytes = new byte[fs.Length];
    
                    fs.Read(bytes, 0, bytes.Length);
    
                    // 设置当前流的位置为流的开始 
    
                    fs.Seek(0, SeekOrigin.Begin);
    
                    fs.Close();
                    fs.Dispose();
                    var client = new MvcCallWCFService.UnZipFileService.ZipServiceClient();
                    client.DoWork();
                    client.ZipFileUpload(bytes, "22-140-133", "bl96");
                }
               byte[] bytes = streamBytes;
    
                // 把 byte[] 写入文件  
                var path = GetTempPath();
    
                //创建文件夹地址(不存在就创建)
                CreateDirectory(path);
    
                //指定文件保存格式
                var filePath = path + @"\A.Zip";
    
                //写入本地临时文件
                using (FileStream fs = new FileStream(filePath, FileMode.Create))
                {
                    BinaryWriter bw = new BinaryWriter(fs);
                    bw.Write(bytes);
                    bw.Close();
                    fs.Close();
                }
            /// <summary>
            /// 得到临时文件
            /// </summary>
            /// <returns></returns>
            private string GetTempPath()
            {
                //获取一个临时文件夹 
                string tempPath = Path.GetTempPath();
    
                string savePath = tempPath + @"UnZipTemp" + new Random().Next(20).ToString();
                CreateDirectory(savePath);
                return savePath;
            }
  • 相关阅读:
    PDF上添加水印
    java调用POI读取Excel
    搭建Linux的VMware Workstation Pro
    js中两种定时器的设置及清除
    SUI使用经验
    List集合与Array数组之间的互相转换
    jquery操作select
    jquery操作CheckBox
    时间格式
    java 获取路径的各种方法
  • 原文地址:https://www.cnblogs.com/LiMin/p/3017307.html
Copyright © 2011-2022 走看看