0

In C# windows application, i have a textbox1 and "create folder" button and "Open created folder!" buttons. when, i give a name to textbox1 and press "create folder", a folder create with that name. In next step i want to open the folder which i have created The problem is that i dont know how to open that folder which i created! i can only open a directory before the name of my folder. How can i get the path in "create folder" button and use this path for opening inside of the folder? Here is my Code:

enter image description here

        private void button1_Click(object sender, EventArgs e)
    {
        //create a folder

        var adr = System.IO.Directory.CreateDirectory(@"C:\Users\aa\Desktop\test2\" + textBox1.Text);

    }

    private void button2_Click(object sender, EventArgs e)
    {
        System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo()
        {
            FileName = (@"C:\Users\aa\Desktop\test2\"),
            UseShellExecute = true,
            Verb = "open"
        });
2
  • 2
    use FileName = (@"C:\Users\aa\Desktop\test2\" + textBox1.Text) Commented Sep 16, 2019 at 13:21
  • Thanks. and how can i open that folder with using of pictureBox name instead of textbox.text? Commented Sep 16, 2019 at 16:06

1 Answer 1

1

Just add the foleder's name to the path of the folder you want to open.

Chagne this:

FileName = (@"C:\Users\aa\Desktop\test2\")

To this:

FileName = (@"C:\Users\aa\Desktop\test2\" + textBox1.Text)
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. and how can i open that folder with using of pictureBox name instead of textbox.text name?
Not sure what you mean by pictureBox name, but you can just replace textbox.text with any property/function/method that returns a string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.