I want to set the rootpath of an executable application. This rootpath should be the same as the path of an item that I select from a ListBox. The code for selecting the item is as follows.
Now what I want is: Whatever I get the output as in the
Console.Writeli ne(path + selecteditem), I would want to set this as a rootpath for an application so as to do rest of the measurements or steps only in tht path/folder.
Is it possible to do something like this?
Thank you in advance for your help.
Code:
namespace Menu
{
public partial class Form1 : Form
{
private Button button;
private ListBox listBox1;
private string selecteditem;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
button = new Button();
button.Text = "Create ListBox";
button.AutoSize = true;
button.Location = new Point(100, 150);
button.Click += button1_Click;
this.Controls.Add(button);
}
private void button1_Click(object sender, EventArgs e)
{
listBox1 = new ListBox();
listBox1.AutoSize = true;
listBox1.Location = new Point(75, 100);
listBox1.MultiColumn = true;
listBox1.BeginUpdate();
listBox1.DoubleClick += listBox1_DoubleClick;
this.Controls.Add(listBox1);
listBox1.Items.Add("N-TYPE1");
listBox1.Items.Add("N-TYPE2");
listBox1.Items.Add("N-TYPE3");
listBox1.Items.Add("N-TYPE4");
listBox1.Items.Add("N-TYPE5");
}
private void listBox1_DoubleClick(object sender, EventArgs e)
{
selecteditem = String.Empty;
string path = "E:\\New Files\\";
string subPath = "\\D1\\";
string subPath2 = "\\S1";
if (listBox1.SelectedItems.Count > 0)
{
selecteditem = listBox1.SelectedItem.ToString();
if (!Directory.Exists(path + "\\" + selecteditem))
{
Directory.CreateDirectory(path + "\\" + selecteditem);
}
if (!Directory.Exists(path + "\\" + selecteditem + subPath))
{
Directory.CreateDirectory(path + "\\" + selecteditem + subPath);
}
if (!Directory.Exists(path + "\\" + selecteditem + subPath2))
{
Directory.CreateDirectory(path + "\\" + selecteditem + subPath2);
}
else
{
//Do nothing
}
Console.WriteLine(path + selecteditem);
listBox1.ClearSelected();
}
}
}
}
Console.Writeli ne(path + selecteditem), I would want to set this as a rootpath for an application so as to do rest of the measurements or steps only in tht path/folder.
Is it possible to do something like this?
Thank you in advance for your help.
Comment