C# FileStream Dispose
来源:互联网 发布:吃什么补肾 知乎 编辑:程序博客网 时间:2024/05/22 18:23
写入一个文件后,马上调用一个函数进行读取处理。
大部分情况下都OK,但是有时候会错误。
Google到stackoverflow上一篇问答里面有模糊的解释:
http://stackoverflow.com/questions/6350224/does-filestream-dispose-close-the-file-immediately
I have some code that writes a file by saving a MemoryStream to a FileStream using MemoryStream.WriteTo(). After the file is closed it is opened up again to read some metdata...
This works about 80 - 90% of the time. The other 20% I get an exception saying the file is "in use by another process".
Does FileStream.Dispose() not release resources synchronously? Is there something going on lower in Win32 land I'm not aware of? I'm not seeing anything obvious in the .Net documentation.
Is this on NTFS? Is the file local or on a remote share? I doubt that it is Dipose() not closing the HANDLE, I think you might be experiencing what the SAMBA developers called Window's "onerous open modes" (especially if a retry of 500-1000ms on the second open succeeds).
看这个意思,这个和底层文件系统有关?
- C# FileStream Dispose
- C#学习之Dispose
- C# Dispose与Close
- c#中的Dispose()
- C#中的Dispose模式
- C# FileStream&StreamWriter
- C# FileStream文件读写
- C# FileStream.Read Method
- C#中FileStream
- C# FileStream数据流
- c#之filestream
- C#里的资源Dispose
- C#中的close与dispose
- Dispose and Finalize in C#
- c# FileStream和StreamWriter用法
- C# FileStream和StreamWriter用法
- C# FileStream 文件读写(转)
- c# FileStream和StreamWriter用法
- Silverlight游戏特效开发(一) : 制作人物光环效果
- Android编程之LayoutInflater的inflate方法实例
- 用JAVA实现广度优先搜索
- iOS平台内存常见问题
- xpath
- C# FileStream Dispose
- linux ps命令介绍
- Impala各版本新特性
- 程序员面试宝典学习记录003
- hdu 5112 A Curious Matt 2014ACM/ICPC亚洲区北京站-重现赛
- 用android:clipChildren来实现红心变大特效
- 密码保护
- JSP分页
- c++学习笔记—c++对txt文件的读取与写入