}\r
}\r
\r
+ /// <summary>\r
+ /// Looks up a localized string similar to You do not have the appropriate folder permissions to write files into the directory you have chosen..\r
+ /// </summary>\r
+ public static string Main_NoPermissionsOnDirectory {\r
+ get {\r
+ return ResourceManager.GetString("Main_NoPermissionsOnDirectory", resourceCulture);\r
+ }\r
+ }\r
+ \r
/// <summary>\r
/// Looks up a localized string similar to No Preset selected..\r
/// </summary>\r
<data name="UserSettings_UnableToLoadSolution" xml:space="preserve">\r
<value>Your user settings file appears to be inaccessible or corrupted. You may have to delete the file and let HandBrake generate a new one.</value>\r
</data>\r
+ <data name="Main_NoPermissionsOnDirectory" xml:space="preserve">\r
+ <value>You do not have the appropriate folder permissions to write files into the directory you have chosen.</value>\r
+ </data>\r
</root>
\ No newline at end of file
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;
+ }
+ }
}
}
return false;\r
}\r
\r
+ if (!DirectoryUtilities.IsWritable(Path.GetDirectoryName(this.CurrentTask.Destination)))\r
+ {\r
+ this.errorService.ShowMessageBox(Resources.Main_NoPermissionsOnDirectory, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);\r
+ return false;\r
+ }\r
+\r
+\r
// Sanity check the filename\r
if (!string.IsNullOrEmpty(this.Destination) && FileHelper.FilePathHasInvalidChars(this.Destination))\r
{\r