diff --git a/src/Main/Base/Project/Src/Project/AbstractProject.cs b/src/Main/Base/Project/Src/Project/AbstractProject.cs index 836919d2a1..5c7e3206dc 100644 --- a/src/Main/Base/Project/Src/Project/AbstractProject.cs +++ b/src/Main/Base/Project/Src/Project/AbstractProject.cs @@ -129,11 +129,14 @@ namespace ICSharpCode.SharpDevelop.Project [ReadOnly(true)] public virtual bool ReadOnly { get { - if (File.Exists(FileName)) { + try { FileAttributes attributes = File.GetAttributes(FileName); return ((FileAttributes.ReadOnly & attributes) == FileAttributes.ReadOnly); + } catch (FileNotFoundException) { + return false; + } catch (DirectoryNotFoundException) { + return true; } - return false; } } diff --git a/src/Main/Base/Project/Src/Project/Solution/Solution.cs b/src/Main/Base/Project/Src/Project/Solution/Solution.cs index a92d5d2dcc..882880fd5c 100644 --- a/src/Main/Base/Project/Src/Project/Solution/Solution.cs +++ b/src/Main/Base/Project/Src/Project/Solution/Solution.cs @@ -219,8 +219,14 @@ namespace ICSharpCode.SharpDevelop.Project public bool ReadOnly { get { - FileAttributes attributes = File.GetAttributes(fileName); - return ((FileAttributes.ReadOnly & attributes) == FileAttributes.ReadOnly); + try { + FileAttributes attributes = File.GetAttributes(fileName); + return ((FileAttributes.ReadOnly & attributes) == FileAttributes.ReadOnly); + } catch (FileNotFoundException) { + return false; + } catch (DirectoryNotFoundException) { + return true; + } } } #endregion @@ -502,7 +508,7 @@ namespace ICSharpCode.SharpDevelop.Project } } } - + if (!newSolution.ReadOnly && (newSolution.FixSolutionConfiguration(newSolution.Projects) || needsConversion)) { // save in new format newSolution.Save();