File Search&Select

ive got a program that retreives info from a text file (data.txt) that is stored in my /bin directory of my VB.net project.

im trying to create a button to bring up a normal windows file explorer to search and then select the appropriate file (whether its stored on floppy,flash,cd,c: etc.).

can i do this in .net?

and if so, how?
LVL 12
minichickenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

planoczCommented:
Do you mean you want to find data.txt
or
Read the Text file and go get the file that is named in the data.txt?
0
minichickenAuthor Commented:
its just a path.

basically the 'browse' for the file must store the path so the function to edit the file will know where the file is.

eg. someone wants to run a spell check on a data.txt and he/she has it on a stiffy disk/flash drive..
      the program must browse and find where this file is stored to run the spell-check

hope this helps!
0
planoczCommented:
I think it will still be faster for the user to find the file with this dialog.

 Public sFileName as string
 
 Public Sub OpenFile()
        ' Create the OpenFileDialog object
        Dim myOpenFileDialog As New OpenFileDialog
        With myOpenFileDialog
            .CheckFileExists = True
            .DefaultExt = "txt"
            .InitialDirectory = "c:\"
            .Multiselect = False
        End With
        ' Use the OpenFileDialog and put the path and name of the selected file in a var.
        If myOpenFileDialog.ShowDialog = DialogResult.OK Then
            sFileName = myOpenFileDialog.FileName
        End If
    End Sub
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

minichickenAuthor Commented:
how do i use the "OpenFileDialog" in vb.net?
0
planoczCommented:
put in new app.


Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Button1 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(200, 180)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(68, 32)
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "Open File"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Controls.Add(Me.Button1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region
    Private sFileName As String
    Private Sub OpenFile()
        ' Create the OpenFileDialog object
        Dim myOpenFileDialog As New OpenFileDialog
        With myOpenFileDialog
            .CheckFileExists = True
            .DefaultExt = "txt"
            .Filter = "Text files(*.txt)|*.txt"
            .InitialDirectory = "c:\"
            .Multiselect = False
        End With
        ' Use the OpenFileDialog and put the path and name of the selected file in a var.
        If myOpenFileDialog.ShowDialog = DialogResult.OK Then
            sFileName = myOpenFileDialog.FileName
        End If
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        OpenFile()
    End Sub
End Class
0
minichickenAuthor Commented:
thanks alot man!

sorry, just one more question:

will this function give the file path (eg a:/expert/data.txt) as a String variable?
0
planoczCommented:
Yes the var sFileName will have the full path and name of the file.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SilversoftCommented:
you wouldnt be able to help me with some cool form design? (ie transparecy, shape-alteration, or plain old cool ****?)
0
planoczCommented:
Silversoft  do you work with minichicken?
Or are you minichicken?

0
minichickenAuthor Commented:
Hi planocz

I (minichicken) logged on Silversoft's machine last time and forgot to logout.
And we work together.... :)
0
planoczCommented:
to help get you started here is some links...

Here is where I found good examples for getting started in VB.Net

.....http://msdn.microsoft.com/vbasic/downloads/samples/101samples.aspx

Link for ASP programs...

http://msdn.microsoft.com/asp.net/downloads/kits/default.aspx 
0
SilversoftCommented:
yeah we all the same
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.