diff --git a/Greenshot/Helpers/PluginHelper.cs b/Greenshot/Helpers/PluginHelper.cs
index 2cefbb29b..b72ff01ce 100644
--- a/Greenshot/Helpers/PluginHelper.cs
+++ b/Greenshot/Helpers/PluginHelper.cs
@@ -209,25 +209,36 @@ namespace Greenshot.Helpers {
return false;
}
+ ///
+ /// Private helper to find the plugins in the path
+ ///
+ ///
+ ///
+ private void findPluginsOnPath(List pluginFiles, String path) {
+ if (Directory.Exists(pafPath)) {
+ try {
+ foreach (string pluginFile in Directory.GetFiles(path, "*.gsp", SearchOption.AllDirectories)) {
+ pluginFiles.Add(pluginFile);
+ }
+ } catch (System.UnauthorizedAccessException) {
+ return;
+ } catch (Exception ex) {
+ LOG.Error("Error loading plugin: ", ex);
+ }
+ }
+ }
+
+ ///
+ /// Load the plugins
+ ///
public void LoadPlugins() {
List pluginFiles = new List();
- if (IniConfig.IsPortable && Directory.Exists(pafPath)) {
- foreach(string pluginFile in Directory.GetFiles(pafPath, "*.gsp", SearchOption.AllDirectories)) {
- pluginFiles.Add(pluginFile);
- }
+ if (IniConfig.IsPortable) {
+ findPluginsOnPath(pluginFiles, pafPath);
} else {
- if (Directory.Exists(pluginPath)) {
- foreach(string pluginFile in Directory.GetFiles(pluginPath, "*.gsp", SearchOption.AllDirectories)) {
- pluginFiles.Add(pluginFile);
- }
- }
-
- if (Directory.Exists(applicationPath)) {
- foreach(string pluginFile in Directory.GetFiles(applicationPath, "*.gsp", SearchOption.AllDirectories)) {
- pluginFiles.Add(pluginFile);
- }
- }
+ findPluginsOnPath(pluginFiles, pluginPath);
+ findPluginsOnPath(pluginFiles, applicationPath);
}
Dictionary tmpAttributes = new Dictionary();