system commands in C#

How do I execute a system command such "cd" or change directory in Visual C#.NET application? I have a button which when clicked invokes the explorer.exe and shows the directory from My Computer. However, I just need to show the user the files on the CDROM drive. Thanks Mukesh

2 Replies

CB Clay Burch Syncfusion Team May 16, 2002 10:20 AM UTC

You can launch explorer.exe using the Process class and set StartInfo.Arguments to start it up in a different folder. private void button1_Click(object sender, System.EventArgs e) { System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = @"explorer.exe"; proc.StartInfo.Arguments = @"D:\"; proc.Start(); }


CB Clay Burch Syncfusion Team May 16, 2002 10:28 AM UTC

I am not sure this is what you want to do in your case, but to execute a DOS command, you can use code such as System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = @"cmd.exe"; proc.StartInfo.Arguments = @"/c cd A:\"; proc.Start();

Loader.
Up arrow icon