What the program is doing is allowing employees to load and run a program file to a machine on the factory floor. The application launches to a default directory on the network that houses many different programs, they select which one they're running and run it.
What I've done is create an admin form so that we can go out to any machine and change the directory they are accessing (more options to change will be added).
So it launches say for "C:\Files\"
. Later I go into the admin form and change it to "D:\Files\"
. I can't seem to then pass that new directory listing to the main form.
MainForm
private void Main_Load(object sender, EventArgs e)
{
txtsaveprogram.Visible = false;
this.Size = new Size(444, 579);
MachineID();
string[] files = System.IO.Directory.GetFiles(tempvar, "*.NC");
foreach (string file in files)
{
string fileName = Path.GetFileName(file);
cmbfiles.Items.Add(fileName);
}
}
Currently tempvar = @"\\hq1\MFG\DNC\Grinders\PR";
AdminForm
namespace MachineConfig
{
public partial class adminconfig : Form
{
public string programdefaultpath { get; set; }
public adminconfig()
{
InitializeComponent();
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
}
public void adminconfig_Load(object sender, EventArgs e)
{
string[] dir = System.IO.Directory.GetDirectories(@"\\hq1\MFG\DNC\");
foreach (string filedir in dir)
{
string dirpath = Path.GetFileName(filedir);
comboBox1.Items.Add(dirpath);
}
}
private void btndirectory_Click(object sender, EventArgs e)
{
string[] subdir = System.IO.Directory.GetDirectories(@"\\hq1\MFG\DNC\" + comboBox1.Text);
foreach (string filesub in subdir)
{
string subdirpath = Path.GetFileName(filesub);
comboBox2.Items.Add(subdirpath);
}
}
private void adminconfig_FormClosing(object sender, FormClosingEventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
}
}
How do I have these newly selected directories now be the directory they're in on the mainform so the dropdown box now displays the new contents of the newly chosen directory?