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; }
转载于:https://www.cnblogs.com/LiMin/archive/2013/04/12/3017307.html
相关资源:垃圾分类数据集及代码