日期:2014-05-17 浏览次数:21199 次
string file= @"C:\Users\Administrator\Desktop\明星证件照\陈好.jpg";
Stream stream = Stream.Null;
using (var fs = File.Open(file, FileMode.Open))
{
stream = fs;
}
uploadPartRequest.InputStream = stream;
ossClient.UploadPart(uploadPartRequest); //出错:Cannot access a closed file
FileStream fs = null;byte[] buffer = null;try{ if (File.Exists(file)) //图片文件的全路径字符串 { fs = new FileStream(file, FileMode.Open); buffer = new byte[fs.Length]; fs.Read(buffer, 0, int.Parse(fs.Length.ToString())); fs.Close(); fs.Dispose(); }}catch{ fs.Close(); fs.Dispose();}return buffer;//图片文件的流