From 3093c60ae90e9758cf1c7c9e1f8ab600f9bd3189 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 28 Feb 2009 20:49:08 +0000 Subject: [PATCH] Fixed exception when an open solution file is deleted. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3827 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- src/Main/Base/Project/Src/Project/AbstractProject.cs | 7 +++++-- .../Base/Project/Src/Project/Solution/Solution.cs | 12 +++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) 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();