private bool CheckFileSystemWriteAccess(string fileName)
{
if (!File.Exists(fileName))
{
try
{
StreamWriter sw = new StreamWriter(fileName);
sw.Close();
Utilities.DeleteFileIfExists(fileName);
}
catch (Exception ex)
{
Factory.GUIController.ShowMessage("Unable to create the file '" + fileName + "' due to an error: " + ex.Message, MessageBoxIcon.Warning);
return false;
}
// File does not exist, but we do have permission to create it
return true;
}
if ((File.GetAttributes(fileName) & FileAttributes.ReadOnly) != 0)
{
Factory.GUIController.ShowMessage("Unable to edit file '" + fileName + "' because it is read-only.", MessageBoxIcon.Warning);
return false;
}
return true;
}