I need to open a file to write some text to it, is there a built in way where the file is created if it doesn’t exist already?
I want to append to this file, and avoid locking it while it is open. But I will be writing to the file if there is an exeption in a loop like:
try
{
}
catch()
{
write to file
}
You can use
File.Openwith aFileMode.OpenOrCreate,FileMode.Append.In either case, if the file has been opened with
FileAccess.WriteorFileAccess.ReadWrite, a new file will be created if one doesn’t exist.