Mega Code Archive

 
Categories / C# Tutorial / File Directory Stream
 

The FileMode and FileAccess

Value Description FileMode.Appendappend to the end of file. FileMode.Createcreate a new output file. Any preexisting file by the same name will be destroyed. FileMode.CreateNewcreate a new output file. The file must not already exist. FileMode.Openopen a preexisting file. FileMode.OpenOrCreateopen a file if it exists, or create the file if it does not already exist. FileMode.Truncateopen a preexisting file, but reduce its length to zero. If you want to restrict access to just reading or just writing, use this constructor: FileStream(string filename, FileMode mode, FileAccess how) 'how' determines how the file can be accessed. 'how' must be one of: FileAccess.Read FileAccess.Write FileAccess.ReadWrite