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
searching using a folderbrowserdialog
Collapse
X
-
Tags: None
-
i am not erroring out i cant find the code to get it to do anythingOriginally posted by shweta123Hi,
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
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 boxComment
-
-
Try This: Not sure if it will work.. but im trying to help none the less lolOriginally posted by computerenigma1 3i made it unclear i mean searching for certian file types using the folderbrowserdi alog
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!Code:Dim FolderBrowser As New FolderBrowserDialog() FolderBrowser.Filter = "Text Files (*.txt)|.txt"
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
-
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=16Comment
-
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 directoriesCode:''' <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 ClassComment
-
Code has changed as you can see i just need it to now search the sub if the check box is checkedCode:''' <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 ClassComment
-
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
-
i need it to search the directories for a certain file type and move it to the destination folderComment
-
>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.aspxComment
-
That is what i am trying to get it to do thanks i am inserting the code as we speekOriginally 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.aspxComment
Comment