标签:nis cep read cat buffer 保存文件 user 本地服务器 本地
private string SaveFileToLocal(string url) { FileStream os = null; FileStream ns = null; try { string savePath = @"C:\Users\Administrator\MyCopy"; if (!Directory.Exists(savePath)) Directory.CreateDirectory(savePath); string fileName = Path.GetFileName(url); string fileFullPath = Path.Combine(savePath, fileName); os = new FileStream(url, FileMode.Open); ns = new FileStream(fileFullPath, FileMode.OpenOrCreate); byte[] tempBuffer = new byte[4096]; int bytesRead = 0; do { bytesRead = os.Read(tempBuffer, 0, tempBuffer.Length); ns.Write(tempBuffer, 0, bytesRead); } while (bytesRead > 0); return fileFullPath; } catch (Exception e) { throw new Exception("保存文件出错,原因:"+e.Message); } finally { ns.Close(); os.Close(); } }
标签:nis cep read cat buffer 保存文件 user 本地服务器 本地
原文地址:https://www.cnblogs.com/zhengwei-cq/p/10260997.html