standards-c-sharp

Don’t swallow exceptions unless you can gracefully recover

Do

var file = File.Open("myfile.txt");
try
{
    AppenData(file);
}
catch (System.UnauthorizedAccessException) // file is ReadOnly
{
    FileInfo fileInfo = new FileInfo(pathToAFile);
    fileInfo.IsReadOnly = false;
    AppendData(file);
    // we gracefully recovered, so the exception can be swallowed
}