searching using a folderbrowserdialog

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • computerenigma13
    New Member
    • Mar 2007
    • 36

    searching using a folderbrowserdialog

    OK i have been looking for some help on a program i am writing i am supposed to use a folderbrowserdi alog but i cant seem to get it to let me search with it and then save to a new place can some one help
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    Can you please specify your Coding if you are getting any error?

    You can search using
    FolderBrowserDi alog1.showDialo g

    And get the path selected using
    FolderBrowserDi alog1.SelectedP ath

    Comment

    • computerenigma13
      New Member
      • Mar 2007
      • 36

      #3
      Originally posted by shweta123
      Hi,

      Can you please specify your Coding if you are getting any error?

      You can search using
      FolderBrowserDi alog1.showDialo g

      And get the path selected using
      FolderBrowserDi alog1.SelectedP ath
      i am not erroring out i cant find the code to get it to do anything
      here is the code:

      Private Sub Buttonsource_Cl ick(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles Buttonsource.Cl ick
      If FolderBrowserDi alog1.ShowDialo g() = DialogResult.OK Then
      TextBoxXSource. Text = FolderBrowserDi alog1.SelectedP ath
      End If
      If CheckBoxsearch. Checked Then
      Else
      End If
      End Sub

      The if and else are for a check box

      Comment

      • computerenigma13
        New Member
        • Mar 2007
        • 36

        #4
        i made it unclear i mean searching for certian file types using the folderbrowserdi alog

        Comment

        • Prose
          New Member
          • Mar 2007
          • 20

          #5
          Originally posted by computerenigma1 3
          i made it unclear i mean searching for certian file types using the folderbrowserdi alog
          Try This: Not sure if it will work.. but im trying to help none the less lol

          Code:
                  Dim FolderBrowser As New FolderBrowserDialog()
                  FolderBrowser.Filter = "Text Files (*.txt)|.txt"
          TextFiles is just an example i used...u can replace this with any kind of file.. such as .doc ------ "Word Document (*.doc)|.doc" again just an example, replace the FolderBrowser.F ilter with the file type u want to use!

          Note: i have not tried this!.. im currently on a computer that doesnt have VB installed.. soo im not all too sure it's just a theory.. lol.. but i hope it helps

          Good Luck!

          Prose.

          Comment

          • computerenigma13
            New Member
            • Mar 2007
            • 36

            #6
            i am retreiving the file types from a text box adn was trying to get the text box to set the filter its a windows app version of this web app http://www.xefteri.com/articles/show.cfm?id=16

            Comment

            • computerenigma13
              New Member
              • Mar 2007
              • 36

              #7
              Code:
              ''' <summary>
              ''' this program take differnt files and moves them form one directory to another 
              ''' </summary>
              ''' <remarks></remarks>
              Public Class Formsource
                  ''' <summary>
                  ''' a search for files of a certain type in the directories 
                  ''' </summary>
                  ''' <param name="sender"></param>
                  ''' <param name="e"></param>
                  ''' <remarks></remarks>
                  Private Sub Buttonsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonsearch.Click
                      If CheckBoxsearch.Checked = True Then
                          'search the sub directories and the directories
                      Else
                          'search only the directories
                      End If
                  End Sub
                  ''' <summary>
                  ''' look for the source of the file to copy 
                  ''' </summary>
                  ''' <param name="sender"></param>
                  ''' <param name="e"></param>
                  ''' <remarks></remarks>
                  Private Sub Buttonsource_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonsource.Click
                      If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then
                          TextBoxXSource.Text = FolderBrowserDialog1.SelectedPath
                      End If
                      If CheckBoxsearch.Checked Then
                      Else
                      End If
              
                  End Sub
                  ''' <summary>
                  ''' looks for the destiantion of the files
                  ''' </summary>
                  ''' <param name="sender"></param>
                  ''' <param name="e"></param>
                  ''' <remarks></remarks>
                  Private Sub Buttondes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttondes.Click
                      If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then
                          TextBoxXdestination.Text = FolderBrowserDialog1.SelectedPath
                      End If
                  End Sub
                  ''' <summary>
                  ''' a button to exit 
                  ''' </summary>
                  ''' <param name="sender"></param>
                  ''' <param name="e"></param>
                  ''' <remarks></remarks>
                  Private Sub Buttonexit_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonexit.Click
                      End
                  End Sub
              End Class
              Here is the code i have even a search button adn a save button for searching adn saving i just need to know how to get the save button to save what i search and find and i need the search button to search trhough directories and sub directories

              Comment

              • computerenigma13
                New Member
                • Mar 2007
                • 36

                #8
                Code:
                ''' <summary>
                ''' this program take differnt files and moves them form one directory to another 
                ''' </summary>
                ''' <remarks></remarks>
                Public Class Formsource
                    ''' <summary>
                    ''' look for the source of the file to copy 
                    ''' </summary>
                    ''' <param name="sender"></param>
                    ''' <param name="e"></param>
                    ''' <remarks></remarks>
                    Private Sub Buttonsource_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonsource.Click
                        If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then
                            TextBoxXSource.Text = FolderBrowserDialog1.SelectedPath
                        End If
                        If CheckBoxsearch.Checked Then
                        Else
                        End If
                
                    End Sub
                    ''' <summary>
                    ''' looks for the destination of the files
                    ''' </summary>
                    ''' <param name="sender"></param>
                    ''' <param name="e"></param>
                    ''' <remarks></remarks>
                    Private Sub Buttondes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttondes.Click
                        If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then
                            TextBoxXdestination.Text = FolderBrowserDialog1.SelectedPath
                        End If
                    End Sub
                    ''' <summary>
                    ''' a button to exit 
                    ''' </summary>
                    ''' <param name="sender"></param>
                    ''' <param name="e"></param>
                    ''' <remarks></remarks>
                    Private Sub Buttonexit_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonexit.Click
                        End
                    End Sub
                    ''' <summary>
                    ''' this button will search and save any file of the specified type 
                    ''' </summary>
                    ''' <param name="sender"></param>
                    ''' <param name="e"></param>
                    ''' <remarks></remarks>
                    Private Sub Buttonsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonsave.Click
                        With FolderBrowserDialog1
                            .Description = "Select your folder"
                            .RootFolder = Environment.SpecialFolder.MyDocuments
                            .ShowNewFolderButton = True
                            If .ShowDialog() = Windows.Forms.DialogResult.OK Then
                                MsgBox(.SelectedPath)
                            End If
                        End With
                    End Sub
                End Class
                Code has changed as you can see i just need it to now search the sub if the check box is checked

                Comment

                • SammyB
                  Recognized Expert Contributor
                  • Mar 2007
                  • 807

                  #9
                  This is how I would design it:

                  At the top of the form there are two textboxes for the input and output directories. After each textbox there is a browse button that uses the FolderBrowseDia log.

                  Under that there are two panels:

                  Left is a CheckedListBox that you populate with a unique list of the file extensions in the input directory.

                  Right is a ListView (with checkboxes) that lists all of the files whose extensions are checked.

                  Both lists should initially be all checked; ie move the entire directory. The CheckedListBox click event would update the File list. The OK button prompts "are you sure?" and then moves the checked files from the input directory to the output directory.

                  In addition, use an ErrorProvider control to prohibit the user from clicking OK until the input & output directories have been chosen.

                  What do you need help with?

                  Comment

                  • computerenigma13
                    New Member
                    • Mar 2007
                    • 36

                    #10
                    i need it to search the directories for a certain file type and move it to the destination folder

                    Comment

                    • SammyB
                      Recognized Expert Contributor
                      • Mar 2007
                      • 807

                      #11
                      >search the directories for a certain file type

                      Use Directory.GetFi les
                      See http://msdn2.microsoft.com/en-us/library/wz42302f.aspx

                      >move it to the destination folder

                      Use File.Move
                      See http://msdn2.microsoft.com/en-us/lib...file.move.aspx

                      Comment

                      • computerenigma13
                        New Member
                        • Mar 2007
                        • 36

                        #12
                        Originally posted by SammyB
                        >search the directories for a certain file type

                        Use Directory.GetFi les
                        See http://msdn2.microsoft.com/en-us/library/wz42302f.aspx

                        >move it to the destination folder

                        Use File.Move
                        See http://msdn2.microsoft.com/en-us/lib...file.move.aspx
                        That is what i am trying to get it to do thanks i am inserting the code as we speek

                        Comment

                        Working...