auto. loading files with my application
-
simple question, im sure its around here somewhere, just couldnt see it. if someone could send a link to it, if nothing else, that would be great. just wondering how to program my application so that it can load a file into the program once the file type is opened. say, a notepad program opening .txt files, or winamp opening .mp3s. how do you do this? edit: i know how to open and read files etc etc, i dont need help there.. im just wondering how i can load the file automatically if it is opened with the program, or where i put the code to do this. Thanks alot, advanced. ------------------------ Jordan. III
-
simple question, im sure its around here somewhere, just couldnt see it. if someone could send a link to it, if nothing else, that would be great. just wondering how to program my application so that it can load a file into the program once the file type is opened. say, a notepad program opening .txt files, or winamp opening .mp3s. how do you do this? edit: i know how to open and read files etc etc, i dont need help there.. im just wondering how i can load the file automatically if it is opened with the program, or where i put the code to do this. Thanks alot, advanced. ------------------------ Jordan. III
First, you app must support command line arguments. You'll have to pick out an open command and the filename to open. Notepad is launched by a command line that looks like this:
C:\WINDOWS\system32\NOTEPAD.EXE C:\Fullpath\filename.txt
Second, check out how .TXT files are associated to Notepad. Open an Explorer window and go to Tools\Folder Options. Click on the File Types tab and scroll down to TXT. Click on it to select it, then click on Advanced. Edit the Open command and you'll see what I'm talking about as far as command lines. RageInTheMachine9532
-
First, you app must support command line arguments. You'll have to pick out an open command and the filename to open. Notepad is launched by a command line that looks like this:
C:\WINDOWS\system32\NOTEPAD.EXE C:\Fullpath\filename.txt
Second, check out how .TXT files are associated to Notepad. Open an Explorer window and go to Tools\Folder Options. Click on the File Types tab and scroll down to TXT. Click on it to select it, then click on Advanced. Edit the Open command and you'll see what I'm talking about as far as command lines. RageInTheMachine9532
-
First, you app must support command line arguments. You'll have to pick out an open command and the filename to open. Notepad is launched by a command line that looks like this:
C:\WINDOWS\system32\NOTEPAD.EXE C:\Fullpath\filename.txt
Second, check out how .TXT files are associated to Notepad. Open an Explorer window and go to Tools\Folder Options. Click on the File Types tab and scroll down to TXT. Click on it to select it, then click on Advanced. Edit the Open command and you'll see what I'm talking about as far as command lines. RageInTheMachine9532
hopefully ull b auto-emailed about this reply iv been looking in2 it and cant seem to find any help for vb.net. i found quite a few sites for vb6 code, it looks like. ive tried it and it doesnt recognize the "Command" variable, or whatever it would be called. Private Sub Form_Load() If Command$ <> "" Then MsgBox "Application started by double clicking" & vbCr & Command$ End If End Sub i got this from here[^]. i searched vb.net's help index, and tried the ex. given with the "Command" thing. cant seem to get it. also, it seems most apps use the command "%1" when opening files that are associated with the app.. any more help? ...appreciated Thanks ------------------------ Jordan. III
-
hopefully ull b auto-emailed about this reply iv been looking in2 it and cant seem to find any help for vb.net. i found quite a few sites for vb6 code, it looks like. ive tried it and it doesnt recognize the "Command" variable, or whatever it would be called. Private Sub Form_Load() If Command$ <> "" Then MsgBox "Application started by double clicking" & vbCr & Command$ End If End Sub i got this from here[^]. i searched vb.net's help index, and tried the ex. given with the "Command" thing. cant seem to get it. also, it seems most apps use the command "%1" when opening files that are associated with the app.. any more help? ...appreciated Thanks ------------------------ Jordan. III
It's not Command$ -- that's old VB6 stuff. Look into the Environment class. You'll use either Environment.CommandLine or Environment.GetCommandLineArgs(). Docs are here[^]. The '%1' is a replacable parameter. Remember DOS batch files? When that command line is executed, the %1 is replaced with the filename (complete path) you double-clicked on. If you double-click on, say, TestFile.txt, Explorer will convert this:
C:\WINDOWS\NOTEPAD.EXE "%1"
to this and execute it:
C:\WINDOWS\NOTEPAD.EXE "C:\Wherever this file sits\TestFile.txt"
RageInTheMachine9532
-
It's not Command$ -- that's old VB6 stuff. Look into the Environment class. You'll use either Environment.CommandLine or Environment.GetCommandLineArgs(). Docs are here[^]. The '%1' is a replacable parameter. Remember DOS batch files? When that command line is executed, the %1 is replaced with the filename (complete path) you double-clicked on. If you double-click on, say, TestFile.txt, Explorer will convert this:
C:\WINDOWS\NOTEPAD.EXE "%1"
to this and execute it:
C:\WINDOWS\NOTEPAD.EXE "C:\Wherever this file sits\TestFile.txt"
RageInTheMachine9532
-
ok sorry for the nagging, etc.. heh Thank you lots, ill read the lib info. Again, thx. ------------------------ Jordan. III
:-DNo problem! RageInTheMachine9532
-
:-DNo problem! RageInTheMachine9532
ok i think iv got it.. at least up to my requirements. by simply using folder options/file types and manually associating the file type with the app, and adding %1, or %[any number] to the parameter list, i can work with it. i simply assign a value to
System.Environment.CommandLine()
and it returns the app path, and the file path which was opened with it. i was thinking way to complex. my next step is to determine how to auto. associate the file types with the app, editing the registry from the app. Thanks. ------------------------ Jordan. III