Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. auto. loading files with my application

auto. loading files with my application

Scheduled Pinned Locked Moved Visual Basic
questionhelptutorial
8 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nadroj
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • N Nadroj

      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

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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

      N 2 Replies Last reply
      0
      • D Dave Kreskowiak

        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

        N Offline
        N Offline
        Nadroj
        wrote on last edited by
        #3

        hmm.. alrighty thanks alot. ill check it out shortly. ill try and let you know how it goes. ------------------------ Jordan. III

        1 Reply Last reply
        0
        • D Dave Kreskowiak

          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

          N Offline
          N Offline
          Nadroj
          wrote on last edited by
          #4

          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

          D 1 Reply Last reply
          0
          • N Nadroj

            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

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            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

            N 1 Reply Last reply
            0
            • D Dave Kreskowiak

              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

              N Offline
              N Offline
              Nadroj
              wrote on last edited by
              #6

              ok sorry for the nagging, etc.. heh Thank you lots, ill read the lib info. Again, thx. ------------------------ Jordan. III

              D 1 Reply Last reply
              0
              • N Nadroj

                ok sorry for the nagging, etc.. heh Thank you lots, ill read the lib info. Again, thx. ------------------------ Jordan. III

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                :-DNo problem! RageInTheMachine9532

                N 1 Reply Last reply
                0
                • D Dave Kreskowiak

                  :-DNo problem! RageInTheMachine9532

                  N Offline
                  N Offline
                  Nadroj
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups