open a file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tido
    New Member
    • Nov 2008
    • 3

    open a file

    here is a easy question for you guys:

    How do I open a file? I don't mean import it in vb, I want to open it using the default program.
    example: I want to open a mp3 using windows media player when I ask my program to do so...


    thanks
  • lotus18
    Contributor
    • Nov 2007
    • 865

    #2
    You can use Shell command for that : )


    Rey Sean

    Comment

    • tido
      New Member
      • Nov 2008
      • 3

      #3
      thanks, with some research I learned how to use shell

      Comment

      • rpicilli
        New Member
        • Aug 2008
        • 77

        #4
        Hi there.

        There is an easy way to open no matter what type is your file.

        Code:
        Process.Start("mymusic.mp3")
        
        Process.Start("myarq.pdf")
        
        Process.Start("mySpreadSheet.xls")
        I hope this help you.

        Comment

        • lotus18
          Contributor
          • Nov 2007
          • 865

          #5
          Originally posted by rpicilli
          Hi there.

          There is an easy way to open no matter what type is your file.

          Code:
          Process.Start("mymusic.mp3")
          
          Process.Start("myarq.pdf")
          
          Process.Start("mySpreadSheet.xls")
          I hope this help you.
          This will only work on .net project. If the OP is using vb 6, shell command will do.


          Rey Sean

          Comment

          • smartchap
            New Member
            • Dec 2007
            • 236

            #6
            Use the following code:

            ShellExecute 0&, "OPEN", "E:\Songs\1 4-Race\05 - Zara Zara Touch Me (Asian RnB Mix).mp3", "", "", 1

            In this replace file name with your filename. Also for this is required:

            Private Declare Function ShellExecute Lib "shell32.dl l" Alias "ShellExecu teA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

            Comment

            • rpicilli
              New Member
              • Aug 2008
              • 77

              #7
              Originally posted by lotus18
              This will only work on .net project. If the OP is using vb 6, shell command will do.


              Rey Sean
              Hi I'm not using dot.net project. I'm using the free version of VB 2008. Looks like Visual Studio but its not. Either way thank you.

              Comment

              • smartchap
                New Member
                • Dec 2007
                • 236

                #8
                Dear rpicilli
                I also am not using vb.net. I am using VB6 and in that it works fine. In vb 2008 u can check and I think it should work.

                Comment

                • lotus18
                  Contributor
                  • Nov 2007
                  • 865

                  #9
                  Originally posted by rpicilli
                  Hi I'm not using dot.net project. I'm using the free version of VB 2008. Looks like Visual Studio but its not. Either way thank you.
                  What I meant is .NET and not actually "project". Sorry for the previous post : )


                  Rey Sean

                  Comment

                  • lotus18
                    Contributor
                    • Nov 2007
                    • 865

                    #10
                    Originally posted by smartchap
                    Dear rpicilli
                    I also am not using vb.net. I am using VB6 and in that it works fine. In vb 2008 u can check and I think it should work.
                    Try to switch to vb .NET and you will be amazed of this language. I swear : )


                    Rey Sean

                    Comment

                    Working...