Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change directories on console application

I am creating a simple explorer program for an assignment on c# and have the directory set to c:\\Windows

How you would be able to change the directory from the default windows to something else in the console.

like image 325
Anthony Bond Avatar asked Jan 10 '13 15:01

Anthony Bond


2 Answers

Directory.SetCurrentDirectory(@"c:\program files\");
like image 166
ken2k Avatar answered Oct 11 '22 17:10

ken2k


You can set Environment.CurrentDirectory property for your directory path.

Gets or sets the fully qualified path of the current working directory.

public static void Main(string[] args)
{
    Environment.CurrentDirectory = "C:\\Windows";
}
like image 28
Soner Gönül Avatar answered Oct 11 '22 18:10

Soner Gönül