Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. file path

file path

Scheduled Pinned Locked Moved ASP.NET
questionxml
9 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shabya
    wrote on last edited by
    #1

    hello, i have an XML file which is located in the root dir of my project. i want to read it via a regular class ( not connected to a web page. i use it as a singleton for various services) when i put only the file name , i get c:\windows\system32\filename.xml how can i retreive the current dir of the website? tnx, avi

    N L J 3 Replies Last reply
    0
    • S shabya

      hello, i have an XML file which is located in the root dir of my project. i want to read it via a regular class ( not connected to a web page. i use it as a singleton for various services) when i put only the file name , i get c:\windows\system32\filename.xml how can i retreive the current dir of the website? tnx, avi

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      Server.MapPath(YourFile)?

      Navaneeth How to use google | Ask smart questions

      S 1 Reply Last reply
      0
      • N N a v a n e e t h

        Server.MapPath(YourFile)?

        Navaneeth How to use google | Ask smart questions

        S Offline
        S Offline
        shabya
        wrote on last edited by
        #3

        Server is not recognized there because the class is not part of a webpage, so what should i do ?

        1 Reply Last reply
        0
        • S shabya

          hello, i have an XML file which is located in the root dir of my project. i want to read it via a regular class ( not connected to a web page. i use it as a singleton for various services) when i put only the file name , i get c:\windows\system32\filename.xml how can i retreive the current dir of the website? tnx, avi

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          System.Web.HttpContext.Current.Server.MapPath("YourFieName")

          S 1 Reply Last reply
          0
          • L Lost User

            System.Web.HttpContext.Current.Server.MapPath("YourFieName")

            S Offline
            S Offline
            shabya
            wrote on last edited by
            #5

            ok , it works. what if i have more than one file with same name at my project? what will the value be ?

            B 1 Reply Last reply
            0
            • S shabya

              ok , it works. what if i have more than one file with same name at my project? what will the value be ?

              B Offline
              B Offline
              Baran M
              wrote on last edited by
              #6

              is that possible to have files which has same name in a folder ... I dont think so ...

              S 1 Reply Last reply
              0
              • B Baran M

                is that possible to have files which has same name in a folder ... I dont think so ...

                S Offline
                S Offline
                shabya
                wrote on last edited by
                #7

                i see, so it looks on the current path i am in and not also in its subs ok , thanks

                modified on Tuesday, April 28, 2009 6:35 AM

                L 1 Reply Last reply
                0
                • S shabya

                  i see, so it looks on the current path i am in and not also in its subs ok , thanks

                  modified on Tuesday, April 28, 2009 6:35 AM

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  Use the following code //Gets the physical path of the application directory string path = System.Web.HttpRuntime.AppDomainAppPath; //Return the file names in the application folder string[] myFiles = System.IO.Directory.GetFiles(path);

                  1 Reply Last reply
                  0
                  • S shabya

                    hello, i have an XML file which is located in the root dir of my project. i want to read it via a regular class ( not connected to a web page. i use it as a singleton for various services) when i put only the file name , i get c:\windows\system32\filename.xml how can i retreive the current dir of the website? tnx, avi

                    J Offline
                    J Offline
                    Jain Vijay
                    wrote on last edited by
                    #9

                    You can use Server.MapPath(.) to retrive current directory of you website.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups