Results 1 to 4 of 4

Thread: [RESOLVED] Search in the folder and sub folders

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2006
    Posts
    91

    Resolved [RESOLVED] Search in the folder and sub folders

    Hai

    i want to search for files in Application folder and its sub folder.

    When i am trying to search from Application.StartupPath it is searching in Debug folder only.

    i want to verify the files availability in all folders and sub folders and should confirm the existense of the file.


    Please help me in this regard

    Thanks and Regards
    Vinay Kumar

  2. #2
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Search in the folder and sub folders

    Check out the DirectoryInfo class.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Search in the folder and sub folders

    Please specify your version when posting. It's as simple as one click.

    If you're using .NET 2.0 then IO.Directory.GetFiles and IO.DirectoryInfo.GetFiles both offer an option to search subfolders. If you're using an older version then you can write your own recursive mthod:
    Code:
    private void GetFiles(string folder)
    {
        foreach (string file in Directory.GetFiles(folder))
        {
            MessageBox.Show(file);
        }
    
        foreach (string subfolder in Directory.GetDirectories(folder))
        {
            this.GetFiles(subfolder);
        }
    }
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2006
    Posts
    91

    Re: Search in the folder and sub folders

    Thank you and sorry for not mentioning version

    i am using c# 2.0 .i got the solution



    Thanks for the guide


    Vinay Kumar

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