Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Changing the directory in a method and call variable elsewhere

$
0
0
Hi i am attempting to change the directory in a method in my program and i was wondering how i would then use the variable from the method to say that the directory has changed in a start screen method
 static void choice4()
        {
            Console.WriteLine("Please enter a new directory to go to: ");
            string newDirectory = Console.ReadLine();
            try
            {

                Directory.SetCurrentDirectory(newDirectory);

            }
            catch (DirectoryNotFoundException n)
            {

                Console.WriteLine("The Directory {0} does not exist", n);

            }
           
            Console.WriteLine("Root directory: {0}", Directory.GetDirectoryRoot(newDirectory));
            Console.WriteLine("Current directory: {0}", Directory.GetCurrentDirectory());

            Console.ReadLine();
            Console.Clear();

            startscreen();
        } 

any help would be much appreciated

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>