diff --git a/Synology Download Station Adapter/Adapter.cs b/Synology Download Station Adapter/Adapter.cs index 6ff4dfe..c09999b 100644 --- a/Synology Download Station Adapter/Adapter.cs +++ b/Synology Download Station Adapter/Adapter.cs @@ -54,6 +54,17 @@ public static Dictionary FileDownloads } } + public static string AssemblyDirectory + { + get + { + string codeBase = Assembly.GetExecutingAssembly().CodeBase; + UriBuilder uri = new UriBuilder(codeBase); + string path = Uri.UnescapeDataString(uri.Path); + return Path.GetDirectoryName(path); + } + } + #endregion #region Static Methods diff --git a/Synology Download Station Adapter/frmDownloadStation.cs b/Synology Download Station Adapter/frmDownloadStation.cs index a419da2..e57529f 100644 --- a/Synology Download Station Adapter/frmDownloadStation.cs +++ b/Synology Download Station Adapter/frmDownloadStation.cs @@ -5,6 +5,7 @@ using System.Data; using System.Drawing; using System.Globalization; +using System.IO; using System.Linq; using System.Net; using System.Text; @@ -60,14 +61,24 @@ private frmDownloadStation() { InitializeComponent(); - // Add a WebSession. - webControl.WebSession = WebCore.CreateWebSession("Session", new WebPreferences() - { - AcceptLanguage = CultureInfo.CurrentCulture.Name + "," + CultureInfo.CurrentCulture.TwoLetterISOLanguageName - }); - this.Width = Settings.Default.SizeX; this.Height = Settings.Default.SizeY; + + try + { + // Add a WebSession. + webControl.WebSession = WebCore.CreateWebSession(Path.Combine(Adapter.AssemblyDirectory, "Session"), new WebPreferences() + { + AcceptLanguage = CultureInfo.CurrentCulture.Name + "," + CultureInfo.CurrentCulture.TwoLetterISOLanguageName + }); + } + catch (Exception ex) + { + Adapter.ShowBalloonTip(ex.Message, ToolTipIcon.Error); + + pbLoadingIndicator.Image = pbLoadingIndicator.ErrorImage; + this.NewIntance(); + } } #endregion diff --git a/Synology Download Station Adapter/frmSettings.cs b/Synology Download Station Adapter/frmSettings.cs index 4531a0b..d65fd93 100644 --- a/Synology Download Station Adapter/frmSettings.cs +++ b/Synology Download Station Adapter/frmSettings.cs @@ -222,7 +222,7 @@ private void addContainerToolStripMenuItem_Click(object sender, EventArgs e) using (OpenFileDialog openFile = new OpenFileDialog()) { openFile.Title = "Select a Container File"; - openFile.Filter = "Container Files (" + string.Join(" ,*", Adapter.FILE_TYPES_ALL).Trim(" ,".ToCharArray()) + ")|" + string.Join(";*", Adapter.FILE_TYPES_ALL).Trim(";".ToCharArray()) + "|All files (*.*)|*.*"; + openFile.Filter = "Container Files (*" + string.Join(" ,*", Adapter.FILE_TYPES_ALL).Trim(" ,".ToCharArray()) + ")|*" + string.Join(";*", Adapter.FILE_TYPES_ALL).Trim(";".ToCharArray()) + "|All files (*.*)|*.*"; openFile.Multiselect = false; if (openFile.ShowDialog() == DialogResult.OK)