Geeks With Blogs
Nat Luengnaruemitchai Geek Blog
Many people use .NET framework library without reading documentation. Sometimes, it just like taking medicine without reading its label. Today, I found that there is a piece of code trying to read AssemblyInfo.cs and change the version of the .NET assembly based on the input. The code seems to work quite well for most of the files except for certain files. In each of those files, there is an extra "]" at the end. It took a while to see that it's using FileMode.OpenOrCreate instead of FileMode.Create. This will cause the FileStream to open that file at position 0 but it will keep the rest of the file intact. Therefore, if the program overwrite the file with shorter content, you will still see some of the old content at the end of the file! Posted on Friday, October 23, 2009 11:00 PM Programming | Back to top


Comments on this post: Peril of FileMode.OpenOrCreate

# qoute
Requesting Gravatar...
you are doing very well .Many people use .NET framework library without reading documentation. Sometimes, it just like taking medicine without reading its label. Today, I found that there is a piece of code trying to read AssemblyInfo.cs and change the version of the .NET assembly based on the input. The code seems to work quite well for most of the files except for certain files.
quotes
Left by hunnyleo8 on May 09, 2011 12:39 PM

Your comment:
 (will show your gravatar)


Copyright © Nat Luengnaruemitchai | Powered by: GeeksWithBlogs.net