Hello! :)
I'm having this problem...
I've made a sort of a notpad, and a MenuStrip with the button Run... but how do I get it to save the textfile in f.ex C:\. Like C:\thing.bat?
Please help! :)
Printable View
Hello! :)
I'm having this problem...
I've made a sort of a notpad, and a MenuStrip with the button Run... but how do I get it to save the textfile in f.ex C:\. Like C:\thing.bat?
Please help! :)
Lets say your notepad app has a textbox where the user types the text and it is called textbox1.
You can use code like this to save the text from that textbox to a file
of course this means the file will be "C:\somefile.bat" everytime since it is hard coded. What you likely want to do, is make use of the "SaveFileDialog" component in the toolbox, so you could bring up a save dialog and have the user select the path and name the file whatever they want. You would then use that filename instead of the hard coded one to save the text to a bat file.Code:Dim myFileName As String = "C:\somefile.bat"
My.Computer.FileSystem.WriteAllText(myFileName, textbox1.text, False)
Add a batch thing to your SaveFileDialog.
vb Code:
o_dl.Filter = "Text Document (*.txt)|*.txt|Batch File (*.bat)|*.bat|All Files (*.*)|*.*"
Thank you! :)
I think the code is okay, because I just want it to be saved somewhere, it doesn't matter! The name doesn't matter either! :) It's just to try out the file that I've made, and the delete it! :)
Thanks for the answer, but I just wanted it to be saved as a .bat without any more actions. :)