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;
            }
  • 相关阅读:
    imp.load_source的用法
    第12周翻译
    第十周学习笔记
    翻译:高级t
    t-sql
    9周学习笔记
    第8周学习笔记
    t-sql的楼梯:超越基本级别6:使用案例表达式和IIF函数
    数据库设计层次3:构建表
    第七周学习笔记
  • 原文地址:https://www.cnblogs.com/LiMin/p/3017307.html
Copyright © 2011-2022 走看看