Worrow Posted February 8, 2004 Posted February 8, 2004 I tried to call "del *.bak" inside my program with process.start. However, since 'del' is not a file so it is not possible to use process.start to call it. I know there are other ways to do the same thing but I just want to use dos command. Any idea how? Thanks in advance. Quote
*Experts* Bucky Posted February 8, 2004 *Experts* Posted February 8, 2004 Have your program create a batch file that contains all the DOS commands you want to execute. Then use Process.Start() to run the batch. Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
dragon4spy Posted February 13, 2004 Posted February 13, 2004 :D Forget about dos and batch file command buddy :cool: Here is vb.net code for you. Dim fs() As String, i As Integer fs = Directory.GetFiles(Directory.GetCurrentDirectory, "*.bat") For i = 0 To UBound(fs) File.Delete(fs(i)) Next Quote Don't judge a man by his look. Don't judge a book by its cover. :D
Leaders dynamic_sysop Posted February 13, 2004 Leaders Posted February 13, 2004 if you want to use the Dos method of deleting files from a folder, here's a quick sample i knocked up for you ... Dim pr As Process Dim args As New ProcessStartInfo("cmd.exe") With args .RedirectStandardInput = True .RedirectStandardOutput = True .UseShellExecute = False .WindowStyle = ProcessWindowStyle.Normal End With pr = Process.Start(args) '/// now lets delete all files with a .txt extension from the folder C:\testing\ '/// you would obviously use *.bak instead of *.txt here ... pr.StandardInput.WriteLine("del C:\testing\*.txt" & Convert.ToChar(13)) '/// chr(13) being Enter key. pr.CloseMainWindow() hope it helps :) Quote
dragon4spy Posted February 13, 2004 Posted February 13, 2004 Hi! Your technique is cool buddy, but in this situation is different. I think to put an elephant into a refrigerator, just open the door and put it in. So... Process.Start("c:\windows\system32\cmd.exe /c del *.bat") Quote Don't judge a man by his look. Don't judge a book by its cover. :D
*Experts* Volte Posted February 13, 2004 *Experts* Posted February 13, 2004 (edited) dragon4spy's method is the best one. Edited February 14, 2004 by Volte Quote
*Gurus* Derek Stone Posted February 14, 2004 *Gurus* Posted February 14, 2004 [msdn]System.IO[/msdn] is the best method... Quote Posting Guidelines
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.