SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Dec 2008
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    checking the exixtence of folder

    in asp.ne i want to check if a folder exixts on the system physically and accordingly do the task
    i used System.IO

    if System.IO.File.Exists(StrFolder) Then

    this checks for the file
    i need to check for the folder and its path

    eg:
    c:\folder1\folder2

  2. #2
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,653
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Have you looked at the documentation for System.IO? There might be another class there that could help.

  3. #3
    SitePoint Zealot
    Join Date
    Nov 2001
    Location
    RI, USA
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's just like File exists, except using Directory class..


    Code Csharp:
    if (System.IO.Directory.Exists(path))
    {
    ...do something
    }
    in1.com | Bootply - Bootstrap playground

  4. #4
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make sure you remember to use Server.MapPath as well.

    Building on aspapp's snippet...

    Code Csharp:
    string path = Server.MapPath(strFolder)
     
    if (System.IO.Directory.Exists(path))
    {
    ...do something
    }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •