summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Utilities
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrakeWPF/Utilities')
-rw-r--r--win/CS/HandBrakeWPF/Utilities/DirectoryUtilities.cs19
1 files changed, 19 insertions, 0 deletions
diff --git a/win/CS/HandBrakeWPF/Utilities/DirectoryUtilities.cs b/win/CS/HandBrakeWPF/Utilities/DirectoryUtilities.cs
index 23b10ede8..5461605d0 100644
--- a/win/CS/HandBrakeWPF/Utilities/DirectoryUtilities.cs
+++ b/win/CS/HandBrakeWPF/Utilities/DirectoryUtilities.cs
@@ -37,5 +37,24 @@ namespace HandBrakeWPF.Utilities
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "HandBrake");
}
}
+
+
+ /// <summary>
+ /// Simple way of checking if a directory is writeable.
+ /// </summary>
+ /// <param name="dirPath">Path to check</param>
+ /// <returns>True if writable</returns>
+ public static bool IsWritable(string dirPath)
+ {
+ try
+ {
+ using (File.Create(Path.Combine(dirPath, Path.GetRandomFileName()), 1, FileOptions.DeleteOnClose)) { }
+ return true;
+ }
+ catch
+ {
+ return false;
+ }
+ }
}
}