private void button1_Click(object sender, EventArgs e)
{
try
{
//This will create a new .bat file in the bat directory.
System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\bat\dirlist.bat");
//The code below will write lines to the .bat file.
//The dir command is used in a Command to list files in the specified directory.
//The > command in this case sends the list to a text file.
file.WriteLine(@"dir C:\Zip\*.zip > C:\bat\dir.txt");
file.WriteLine("exit");
file.Close();
//The System.Dignostics.Process Process Class allows a Visual Studio Program
//to execute another application
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents = false;
//This line executes the .bat file created above.
proc.StartInfo.FileName = @"C:\bat\dirlist.bat";
proc.Start();
}
catch (System.Exception err)
{
System.Windows.Forms.MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}This free website was made using Yola.
No HTML skills required. Build your website in minutes.
Go to www.yola.com and sign up today!
Make a free website with Yola