I have a file path that might exist or might not exist.
I want to create / override the file, and i have this code:
string filePath = GetFilePath();
using (FileStream file = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None))
{
xDoc.Save(file);
}
When i call using (FileStream file ...)
and the file doesn't exist, it throws an Could not find a part of the path...
error.
I am doing something wrong? shouldn't it create the file if doesn't exist?