i'm writing some values which are global to the whole app. these values can change depending on the user.
// create GLOBAL SETTINGS
public static class MyGlobals
{
public static string userName = "userName";
public static string pdfPath = @"C:\mypdfs\"; // deafult value, changes
public static string FontName = "Gotham Book";
}
now in another part of the app, the user can update the pdfPath.
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
MyGlobals.pdfPath = folderBrowserDialog1.SelectedPath;
}
this all works, but if the user double clicks the file, it should open, but i get a win32 exception.
// execute selected file
int index = this.listBox1.IndexFromPoint(e.Location);
if (index != System.Windows.Forms.ListBox.NoMatches)
{
var file = listBox1.SelectedItem.ToString();
Process.Start(MyGlobals.pdfPath + file);
listBox1.Visible = false;
filesPnl.Visible = false;
listBox1.Items.Clear();
}
in addition, if i select user/My Documents/ it populates the list correctly, but it removes "My ", so MyGlobals.pdfPath = user/documents + fileName.pdf
Which i assume is my win32 exception.. Have i missed something, or is there a better way to achieve a global variable which can update and always loads with the app..
Thanks..