var filePath = Path.Combine(directoryPath, guidstr + Path.GetExtension(files[0].FileName));
resfilePath = resfilePath + guidstr + Path.GetExtension(files[0].FileName);
var fileStream = System.IO.File.Open(filePath, FileMode.Create);//OpenOrCreate:文件存在打开,不存在创建。Create:文件存在覆盖,不存在创建。
fileStream.Position = fileStream.Length;
Stream stream = files[0].OpenReadStream(); //获取文件数据
stream.Position = 0;
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, (Int32)stream.Length);
fileStream.Write(bytes, 0, bytes.Length);
fileStream.Close();
fileStream.Dispose();
Stream读写文件
最新推荐文章于 2023-09-04 15:57:09 发布