Relative paths

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sneha0608
    New Member
    • Oct 2007
    • 11

    #1

    Relative paths

    Hello all,Can anyone pls tell me how to specify relative paths in a website??
    i have created a website and want to access a text file present in the website root directory.i want to know the no. of records in that text file
    i have written the following code
    int length = new StreamReader(@" \Files\Names.tx t").ReadToEnd() .Split(new char[] { '\n' }).Length;
    It is giving file not found exception!
    Plz help
    Thanks in advance
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Welcome to TSDN. You need to think about what the path is relative to - localhost?

    Comment

    • sneha0608
      New Member
      • Oct 2007
      • 11

      #3
      Thanks
      Do you mean to say that running website in filesystem would make a difference??
      i have used the following code now
      TextReader tr = new StreamReader(Sy stem.AppDomain. CurrentDomain.B aseDirectory + "\\Library\\Nam es.txt");
      will dis work with localhost??

      Comment

      • Shashi Sadasivan
        Recognized Expert Top Contributor
        • Aug 2007
        • 1435

        #4
        i think so,
        You could also use Server.MapPath

        Cheers

        Comment

        Working...