Results 1 to 9 of 9

Thread: directory search

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2018
    Posts
    6

    directory search

    I want to know if directory search in a form is usefull when I want to search on my harddisk for pdf files with a specific name that I type in a textbox. And show all the files that he found in another textbox or other.
    How I have to do that ? Is there an other way to do that ?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: directory search

    This is a bizarre question.
    Quote Originally Posted by pipopol View Post
    I want to know if directory search in a form is usefull when I want to search on my harddisk for pdf files with a specific name that I type in a textbox.
    If you want to search for files then yes, searching for files is useful.
    Quote Originally Posted by pipopol View Post
    How I have to do that ? Is there an other way to do that ?
    You want us to show you two different ways?

    There's lots of information out there about searching for files already. What have you tried and where are you stuck? We can certainly help but you really ought to make an effort for yourself first. You don't know that you can't do it if you don't try.

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2018
    Posts
    6

    Re: directory search

    Quote Originally Posted by jmcilhinney View Post
    This is a bizarre question.

    If you want to search for files then yes, searching for files is useful.

    You want us to show you two different ways?

    There's lots of information out there about searching for files already. What have you tried and where are you stuck? We can certainly help but you really ought to make an effort for yourself first. You don't know that you can't do it if you don't try.


    Sure, but it is not really helping me,
    first problem : I am 54 years old, and I want just to make one more program, last program I was make is in VB6 about 15 years ago. Its already 3 days I am looking for a solution. I am not in the mood anymore to learn the complete language. I know you are going to say that we are never to old to learn someting, But it's not helping.
    second problem : I am not a native speaker or writer in English.
    You are my last help that I can get. If not, I let go the program.

  4. #4
    Fanatic Member
    Join Date
    Dec 2007
    Location
    West Yorkshire, UK
    Posts
    791

    Re: directory search

    I understand the issues trying to work in a foreign language very well so I have some sympathy with that.

    A quick search online found this:
    https://docs.microsoft.com/en-us/dot...nd-directories

    It does not do exactly what you need it to do but I think you will be able to adapt it very easily with your VB6 knowledge.

    If you are still having trouble after you have tried to adapt that code, post back with your issues and someone will be able to help you fix it.

  5. #5
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,423

    Re: directory search

    Hi Pipopol,

    Here is an example of how you might go about it. Probably not the best example, but it'll give you the idea.
    It's in a .zip file in OneDrive, to run the example, enter the file path of your directory in the textbox and click 'Seek'.


    Poppa
    Along with the sunshine there has to be a little rain sometime.

  6. #6
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: directory search

    Good luck,

    Code:
        ''' <summary>
        ''' look for a file
        ''' </summary>
        ''' <param name="StartLookingHere">folder to start in.  will look in all folders beneath.</param>
        ''' <param name="FileNameToLookFor">filename to look for.  can have wild cards</param>
        ''' <returns>list of file names</returns>
        ''' <remarks></remarks>
        Private Function LookForFile(StartLookingHere As String,
                                        FileNameToLookFor As String) As List(Of String)
            Dim rv As New List(Of String)
            Try
                rv.AddRange(IO.Directory.GetFiles(StartLookingHere, FileNameToLookFor, IO.SearchOption.TopDirectoryOnly))
                Dim ds() As String = IO.Directory.GetDirectories(StartLookingHere)
                For Each d As String In ds
                    Try
                        rv.AddRange(LookForFile(d, FileNameToLookFor))
                    Catch ex As Exception
                        'ignore
                    End Try
                Next
            Catch ex As Exception
                'ignore
            End Try
            Return rv
        End Function
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  7. #7

    Thread Starter
    New Member
    Join Date
    Apr 2018
    Posts
    6

    Re: directory search

    Thanks Mate, It was helping me a lot. I still changed some things and now its work perfect.

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: directory search

    If your issue is resolved, please use the Thread Tools menu to mark the thread Resolved, so we can see that you need no more help without opening the thread.

  9. #9
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,423

    Re: directory search

    Quote Originally Posted by jmcilhinney View Post
    If your issue is resolved, please use the Thread Tools menu to mark the thread Resolved, so we can see that you need no more help without opening the thread.
    Hi John,

    I did consider sending a similar message to Pipopol myself, although since he / she is new to the forum I'd've explained how to do that in a private message rather than publicly.

    I didn't know to which of us his / her last message was addressed to, but then again English isn't his / her first language.


    Poppa
    Along with the sunshine there has to be a little rain sometime.

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