我想知道ASP.NET C#中的HttpPostedFile.SaveAs
函数是否是阻塞调用。
答案 0 :(得分:10)
是(来自反射器的片段):
FileStream s = new FileStream(filename, FileMode.Create);
try
{
this._stream.WriteTo(s);
s.Flush();
}
finally
{
s.Close();
}
它不会使用BeginWrite
和EndWrite
,因此它会阻止。
如果您想知道_stream.WriteTo(s);
做了什么:
internal void WriteTo(Stream s)
{
if ((this._data != null) && (this._length > 0))
{
this._data.WriteBytes(this._offset, this._length, s);
}
}
再次阻止。