Newbie Question - Scan
Is there a way to make my program scan its directory for all the .dll files it needs to run? At the moment if there's a file missing it crashes but i want to add an exception that will bring up a message box to tell me which file is missing before the program attempts to run?
Sam HobbsPosted Jan 12, 2011, 10:17 AM
Keenan MolverPosted Jan 11, 2011, 3:16 PM
Was having trouble but then it was a stupid mistake on my side, was referencing (thinks thats the right term) the dlls in the Form1_Load and not in the methods which required them so I just moved them to their respective methods and now its working hundreds.
Thanks again :)
FroglegPosted Jan 11, 2011, 2:11 PM
string[] myDlls = new string[5];
bool dllOK = true;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
chkDll();
if (dllOK == false)
{
//stop something
}
}
public void chkDll()
{
myDlls[0] = (Application.StartupPath + "\\test1.dll");
myDlls[1] = (Application.StartupPath + "\\test2.dll");
myDlls[2] = (Application.StartupPath + "\\test3.dll");
myDlls[3] = (Application.StartupPath + "\\test4.dll");
myDlls[4] = (Application.StartupPath + "\\test5.dll");
foreach (string f in myDlls)
{
if (File.Exists(f) == false)
{
string fp = Path.GetFileName(f);
MessageBox.Show("Required file is missing " + '"' + fp + '"');
dllOK = false;
}
}
}