protected EnsureCanWrite ( string name ) : void | ||
name | string | |
return | void |
protected internal virtual void EnsureCanWrite(string name)
{
if (!directory.Exists)
{
try
{
directory.Create();
}
catch
{
throw new System.IO.IOException("Cannot create directory: " + directory);
}
}
FileInfo file = new FileInfo(Path.Combine(directory.FullName, name));
if (file.Exists) // delete existing, if any
{
try
{
file.Delete();
}
catch
{
throw new System.IO.IOException("Cannot overwrite: " + file);
}
}
}