We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

system commands in C#

Thread ID:

Created:

Updated:

Platform:

Replies:

257 May 16,2002 02:52 AM May 16,2002 06:28 AM Windows Forms 2
loading
Tags: FAQ
Mukesh Motwani
Asked On May 16, 2002 02:52 AM

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

Clay Burch [Syncfusion]
Replied On May 16, 2002 06:20 AM

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(); }

Clay Burch [Syncfusion]
Replied On May 16, 2002 06:28 AM

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();

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;