Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8102263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:12:00+00:00 2026-06-05T23:12:00+00:00

I am relatively new in C#. My question is: I have created a MenuStrip.

  • 0

I am relatively new in C#. My question is: I have created a MenuStrip. I want to create with ButtonCreate_Click a Folder under the Directory path. So how can use the path in the Function buttonCreate? Is that possible?

    private void buttonCreate_Click(object sender, EventArgs e)
    {

        string MyFileName = "Car.txt";

        string newPath1 = Path.Combine(patheto, MyFileName);
        //Create a folder in the active Directory
        Directory.CreateDirectory(newPath1);
    }

    private void DirectoryPathToolStripMenuItem_Click(object sender, EventArgs e)
    {
        string patheto = @"C:\temp";
        Process.Start(patheto);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:12:01+00:00Added an answer on June 5, 2026 at 11:12 pm

    Because you are declaring patheto in the menu items click event it is only a local variable to that scope. If you create a property for your form, then that property can be used within the forms scope. Something like this:

    private string patheto = @"C:\temp";
    
    private void buttonCreate_Click(object sender, EventArgs e)
    {
    
        string MyFileName = "Car.txt";
    
        string newPath1 = Path.Combine(patheto, MyFileName);
        // Create a folder in the active Directory
        Directory.CreateDirectory(newPath1);
    }
    
    private void DirectoryPathToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Process.Start(patheto);
    }
    

    This means that your variable patheto can be accessed anywhere within the form. What you have to remember is that wherever you declare your variables, they will only be accessible in that function/class or child functions/methods.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’m relatively new to Ruby, Sinatra, and DataMapper, but have a question about DataMapper
Im relatively new to the Android world but I have a quick question. I
I'm relatively new to SVN and have a rather basic question. I have several
I'm relatively new to using WPF and the MVVM architecture. I have a question
We use UCM for development. We create streams under streams, like this Question is
I am relatively new to Matlab and have a question about creating a logical
I am relatively new to BDD and I have a question regarding scenario outlines.
I am relatively new to world of programming. I have a few performance questions:
I am relatively new to XSL and I think this is a basic question.
This may be a silly question, but as someone relatively new to PHP, I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.