-
Feb 27th, 2012, 08:06 AM
#1
Thread Starter
Member
[RESOLVED] Dynamic folder serarch when searching for files
I have a file search that I want the user to select the folder they are searching the file in
At the moment I have
If Check.Text = "Correct" Then
If My.Computer.FileSystem.FileExists("C:\Systems\file.txt") Then
1CheckBox.Checked() = True
Else
1CheckBox.Checked = False
End If
However this check will be used for various files and its not usable if the FileExists directory stays the same ie searching the same folder and file for different records. I have a FolderBrowseDialog that I want the user to select the folder first in where to search and then within this chosen folder the static file will be checked. I have this as my folderbrowsedialog:
Dim Browser As New FolderBrowserDialog
Browser.Description = "Please select ."
Browser.ShowNewFolderButton = False
Browser.RootFolder = "c:\"
Browser.SelectedPath = "c:\windows"
If Browser.ShowDialog = Windows.Forms.DialogResult.OK Then
Me.text.Text = Browser.SelectedPath
End If
I tried adding in this code to the actual file check to encoporated the dynamic folder search but its bringing up errors and not working, I have this:
Dim path As String = "Browser"
Dim f As ReadOnlyCollection(Of String) = My.Computer.FileSystem.GetFiles("test.xlsx")
If My.Computer.FileSystem.FileExists("test.xlsx") Then
Box.Checked() = True
Any help would be amazing as my VB knowledge is not the strongest
-
Feb 27th, 2012, 08:12 AM
#2
Re: Dynamic folder serarch when searching for files
So, basically you want the user to select a folder and then test whether a file with a specific name exists in that folder, correct? If so then use the FolderBrowserDialog and get the folder path as a String from its SelectedPath property. Use My.Computer.FileSystem.CombinePath to join that folder path with your file name. You can then pass that result, which is another String, to the My.Computer.FileSystem.FileExists.
-
Feb 27th, 2012, 08:13 AM
#3
Thread Starter
Member
Re: Dynamic folder serarch when searching for files
Thanks for the quick reply I will try that
-
Feb 28th, 2012, 06:59 AM
#4
Thread Starter
Member
Re: Dynamic folder serarch when searching for files
I got it to work, thank you so much!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|