Browse Source

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
shortcuts
Daniel Grunwald 17 years ago
parent
commit
3093c60ae9
  1. 7
      src/Main/Base/Project/Src/Project/AbstractProject.cs
  2. 12
      src/Main/Base/Project/Src/Project/Solution/Solution.cs

7
src/Main/Base/Project/Src/Project/AbstractProject.cs

@ -129,11 +129,14 @@ namespace ICSharpCode.SharpDevelop.Project @@ -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;
}
}

12
src/Main/Base/Project/Src/Project/Solution/Solution.cs

@ -219,8 +219,14 @@ namespace ICSharpCode.SharpDevelop.Project @@ -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 @@ -502,7 +508,7 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
}
if (!newSolution.ReadOnly && (newSolution.FixSolutionConfiguration(newSolution.Projects) || needsConversion)) {
// save in new format
newSolution.Save();

Loading…
Cancel
Save