diff options
author | sr55 <[email protected]> | 2016-06-09 20:35:11 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2016-06-09 20:35:28 +0100 |
commit | cea9d238dbc4c09788604a15672145bde5fad29e (patch) | |
tree | 0562a91de34e8eccb0c649569e738bc7e2ecdfce /win/CS/HandBrakeWPF/Utilities | |
parent | dbc9a88a30efe853ab8d061d1fca7e6a501dc6ea (diff) |
WinGui: Check directory permissions before adding a job to the queue for processing. Fixes #219
Diffstat (limited to 'win/CS/HandBrakeWPF/Utilities')
-rw-r--r-- | win/CS/HandBrakeWPF/Utilities/DirectoryUtilities.cs | 19 |
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; + } + } } } |