我让他遵循代码
HttpPostedFileBase files = Request.Files[0];
Stream fileStream = files.InputStream;
using (Stream file = System.IO.File.OpenWrite(originalImage))
{
StreamUtil.CopyStream(fileStream, file);
file.Close();
fileStream.close();
fileStream.dispose();
}
// here is CopyStream method
public static void CopyStream(Stream input, Stream output)
{
var buffer = new byte[8*1024];
int len;
while ((len = input.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, len);
}
}
当我尝试两次写入同一个文件时,我得到
The process cannot access the file \u0027D:FILENAME because it is being used by another process
我怎样才能关闭它?所以一旦请求写入完成,它将被关闭?