I am having trouble accessing two of my variables. I have looked on the internet and found that I need to use something like form.dlg.selectedpath
to call it but I get three errors. One says form.dlg is inaccessible the next says an object reference is required. I also try to access another one and that says form does not contain definition for dlg2.
This is the code I want the variables in.
var di = new DirectoryInfo(Form1.dlg.SelectedPath);
di.CopyTo(Form1.dlg2.SelectedPath, true);
This is my code I am geting one variable from
public partial class Form1 : Form
{
FolderBrowserDialog dlg = new FolderBrowserDialog();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
if (dlg.ShowDialog() == DialogResult.OK)
And the second variable is referenced from here.
private void button1_Click(object sender, EventArgs e)
{
FolderBrowserDialog dlg2 = new FolderBrowserDialog();
if (dlg2.ShowDialog() == DialogResult.OK)
//do whatever with dlg.SelectedPath
{
backgroundWorker1.RunWorkerAsync(dlg2.SelectedPath);
}
}
Any help will be appreciated.