Open with help...
Okay to put it simple I've made a text editor myself… it works but I want to know how I could have it as a default text editor….
When you open a file you can choose "Open With" then your program… for example if you chose Notepad then whatever you chose would be opened in Notepad… how would I get the to work with my text editor?
That was a strange way to describe things wasn't it…
Btw… I made it in VB.NET Download the old one here: http://darkpanther.freehostia.com/downloads/ That was the old Beta… it's been changed a lot since…
When you open a file with a program, what it actually does is open the program with the file's name and path as the first argument. For example, if you open C:\test.txt with notepad.exe this is what will happen (seen as it works on the DOS prompt)
notepad.exe C:\test.txt
And the application notepad is written to open the first argument as a text file. Firefox is written to open the first argument as an URL, OllyDbg is written to debug the file in the first argument etc.
What you must do is to make the application check for arguments when you run it, and if there are any, make it load the first argument as a textfile.
Googled for vb.net arguments and found some examples.
This should be enough to be able to get them, then just make it load the first argument. (sorry for not telling more, but I'm not a vb coder :angry: ) http://www.vb-helper.com/howto_net_list_command_line_arguments.html http://www.programmers-corner.com/sourcecode/113
Okay… I think it should be something like this:
If sArgs(0) = "" Then
' Do nothing
Else
Dim filecont As String
Dim oFile As System.IO.File
Dim oRead As System.IO.StreamReader
oRead = oFile.OpenText(sArgs(0))
filecont = oRead.ReadToEnd()
MainBox.Text = filecont
oRead.Close()
End If
End Sub```
... I'm pretty sure it's something like that but that doesn't work... any ideas?