validating a path in C#

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?UGF1bA==?=

    validating a path in C#

    Hi I have an application that allows the user to set paths to folders as well
    as deleting these paths. Is there a way to check if the path is valid as my
    code fails when trying to delete a non valid path.
    fi = new FileInfo(Server .MapPath("paths tring");//run time failure here
    --
    Paul G
    Software engineer.
  • Mark Rae [MVP]

    #2
    Re: validating a path in C#

    "Paul" <Paul@discussio ns.microsoft.co mwrote in message
    news:D3CC0C12-2F0F-48EF-8D1B-2688C35BE8F0@mi crosoft.com...
    Hi I have an application that allows the user to set paths to folders as
    well
    as deleting these paths. Is there a way to check if the path is valid as
    my
    code fails when trying to delete a non valid path.
    fi = new FileInfo(Server .MapPath("paths tring");//run time failure here




    --
    Mark Rae
    ASP.NET MVP


    Comment

    • =?Utf-8?B?UGF1bA==?=

      #3
      Re: validating a path in C#

      ended up using
      string validpath = "path";
      if (Directory.Exis ts(validpath)== true)
      {}
      else
      {}
      --
      Paul G
      Software engineer.


      "Juan T. Llibre" wrote:
      using System.IO;
      >
      if (File.Exists("c :\somedir\somef ile.ext"))
      {
      // Do what you want to do.
      }
      >
      >
      >
      >
      >
      >
      Juan T. Llibre, asp.net MVP
      asp.net faq : http://asp.net.do/faq/
      foros de asp.net, en español : http://asp.net.do/foros/
      =============== =============== ========
      "Paul" <Paul@discussio ns.microsoft.co mwrote in message news:D3CC0C12-2F0F-48EF-8D1B-2688C35BE8F0@mi crosoft.com...
      Hi I have an application that allows the user to set paths to folders as well
      as deleting these paths. Is there a way to check if the path is valid as my
      code fails when trying to delete a non valid path.
      fi = new FileInfo(Server .MapPath("paths tring");//run time failure here
      --
      Paul G
      Software engineer

      Comment

      • Juan T. Llibre

        #4
        Re: validating a path in C#

        re:
        !ended up using

        Cool...



        Juan T. Llibre, asp.net MVP
        asp.net faq : http://asp.net.do/faq/
        foros de asp.net, en español : http://asp.net.do/foros/
        =============== =============== ========
        "Paul" <Paul@discussio ns.microsoft.co mwrote in message news:40279FB6-1137-44CF-839A-CC2A54DCADBD@mi crosoft.com...
        ended up using
        string validpath = "path";
        if (Directory.Exis ts(validpath)== true)
        {}
        else
        {}
        --
        Paul G
        Software engineer.
        >
        >
        "Juan T. Llibre" wrote:
        >
        >using System.IO;
        >>
        >if (File.Exists("c :\somedir\somef ile.ext"))
        > {
        > // Do what you want to do.
        > }
        >>
        >>
        >>
        >>
        >>
        >>
        >Juan T. Llibre, asp.net MVP
        >asp.net faq : http://asp.net.do/faq/
        >foros de asp.net, en español : http://asp.net.do/foros/
        >============== =============== =========
        >"Paul" <Paul@discussio ns.microsoft.co mwrote in message news:D3CC0C12-2F0F-48EF-8D1B-2688C35BE8F0@mi crosoft.com...
        Hi I have an application that allows the user to set paths to folders as well
        as deleting these paths. Is there a way to check if the path is valid as my
        code fails when trying to delete a non valid path.
        fi = new FileInfo(Server .MapPath("paths tring");//run time failure here
        --
        Paul G
        Software engineer

        Comment

        Working...