I'm guessing you have a textbox that the user types the batch code into. I'll use that in my example. If not, you should still be able to get the idea. I think using "System.IO.File.WriteAllText" will work for you. You can also use a stream writer object as well but I'll leave that for you to explore. The StreamWriter class is found in the "System.IO" namespace. Take a look at this code and see if you can work it into your application. If you have any trouble let me know.
'This will over-write the file. You may want to check
'for it's existence and ask the user if they want to over-write it.
IO.File.WriteAllText("c:\test.bat", TextBox1.Text)
'To check for a files existance and ask if it's okay to over-write
'you could use
If IO.File.Exists("c:\test.bat") Then
If MsgBox("This file already exists. Would you like to save anyway?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
IO.File.WriteAllText("c:\test.bat", TextBox1.Text)
End If
End If
End Sub
Enter your message below
Sign in or Join us (it's free).