Results 1 to 8 of 8

Thread: Browse for file?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2008
    Posts
    19

    Browse for file?

    I'm really confused with the whole idea, I want it to browse for a file then run it, but the things in toolbox doesnt import anything!

    I want textbox1 to have a button next to it saying "Browse" you click that then click the .exe and it pastes the address of it to the textbox1

    Any help will be thanked..THANK YOU!
    Last edited by johnathonn; Jun 8th, 2008 at 09:07 AM.

  2. #2
    Lively Member
    Join Date
    Jun 2007
    Location
    Canada
    Posts
    86

    Re: Browse for file?

    Well, you can check to see if the file is there by doing:

    Code:
        Public Function FileExists(ByVal FileFullPath As String) As Boolean
            Dim f As New IO.FileInfo(FileFullPath)
            Return f.Exists
        End Function
    
        Public Function FolderExists(ByVal FolderPath As String) As Boolean
            Dim f As New IO.DirectoryInfo(FolderPath)
            Return f.Exists
        End Function

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2008
    Posts
    19

    Re: Browse for file?

    thats a nice bit of code, thank you

    Would i need to project properties and set up my settings for that code? How would it first of all work if i can't browse for the file?

    Many thanks, John

  4. #4
    Lively Member
    Join Date
    Jun 2007
    Location
    Canada
    Posts
    86

    Re: Browse for file?

    Well, if you want to run an exe, use this:

    Code:
    Shell("c:\windows\notepad.exe")
    Or are you trying to make it load a dialog box, so you can pick the file?
    Last edited by Deathader; Jun 8th, 2008 at 09:34 AM.

  5. #5
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424

    Re: Browse for file?

    vb.net Code:
    1. Private Sub btnBrowse_Click( _
    2.     ByVal sender As System.Object, _
    3.     ByVal e As System.EventArgs _
    4. ) Handles btnBrowse.Click
    5.  
    6.     Dim openFileDlg As New OpenFileDialog
    7.     openFileDlg.CheckFileExists = True
    8.     If openFileDlg.ShowDialog = Windows.Forms.DialogResult.OK Then
    9.         TextBox1.Text = openFileDlg.FileName
    10.     End If
    11.     openFileDlg.Dispose()
    12. End Sub

  6. #6
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424

    Re: Browse for file?

    Quote Originally Posted by Deathader
    Well, if you want to run an exe, use this:

    Code:
    Shell("c:\windows\notepad.exe")
    Or are you trying to make it load a dialog box, so you can pick the file?
    It's better to do it the .NET way.
    vb.net Code:
    1. Process.Start("c:\windows\notepad.exe")

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jun 2008
    Posts
    19

    Re: Browse for file?

    Thank you very much! Code works perfect! Would be very handy for future need for any other one!

    THANKS AGAIN LIFE SAVER!

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jun 2008
    Posts
    19

    Re: Browse for file?

    I eventually used this for the loading of the program and it works a treat

    Code:
    Dim startInfo As System.Diagnostics.ProcessStartInfo
            Dim pStart As New System.Diagnostics.Process
            startInfo = New System.Diagnostics.ProcessStartInfo(TextBox3.Text)
            pStart.StartInfo = startInfo
            pStart.Start()
            pStart.WaitForExit()
    Then it will wait untill it has loaded to carry on the script, works great!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width