How to get current working path in C#.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bina
    New Member
    • Mar 2007
    • 2

    How to get current working path in C#.net

    Hi,
    I m new in c#.net . In C#.net, how i will get the current working path? when i used following function "Application.St artupPath" then it show the executable path.(e:\Projec t\DataList\bin\ debug). But i have created my project at the project directory. Now i want to get the path (e:\Project\Dat aList\). How i will get this? IS there any solution to solve this problem? I have created my crystal report file in the "e:\Project\Dat aList\" directory. How i will get the path when i will create installation file? Is there any solution to solve this problem? Please help me about this. Is there anybody who can help me?

    With regards
    Bina
  • Ripendra007
    New Member
    • Feb 2007
    • 27

    #2
    store the path that u got by application.sta rtupPath in string variable like test
    then split that path using the function split('/') and stored in to another variable and use

    Bye hav a nice time

    Comment

    • rac19
      New Member
      • Mar 2007
      • 3

      #3
      bina,
      you can use simply path=@"\bin\deb ug";
      by default the application directory will be the project directory


      Originally posted by Bina
      Hi,
      I m new in c#.net . In C#.net, how i will get the current working path? when i used following function "Application.St artupPath" then it show the executable path.(e:\Projec t\DataList\bin\ debug). But i have created my project at the project directory. Now i want to get the path (e:\Project\Dat aList\). How i will get this? IS there any solution to solve this problem? I have created my crystal report file in the "e:\Project\Dat aList\" directory. How i will get the path when i will create installation file? Is there any solution to solve this problem? Please help me about this. Is there anybody who can help me?

      With regards
      Bina

      Comment

      • strandberg
        New Member
        • Feb 2007
        • 2

        #4
        Originally posted by Bina
        ...how i will get the current working path
        Is this what you are looking for?

        Code:
        string cwd = System.IO.Directory.GetCurrentDirectory();
            Console.WriteLine("cwd is '{0}'", cwd);
        
            if (cwd.EndsWith("\\bin\\Debug"))
            {
              cwd = cwd.Replace("\\bin\\Debug", "");
              Console.WriteLine("updated cwd is '{0}'", cwd);
            }
        For me the output is:
        cwd is 'C:\Documents and Settings\per\Lo cal Settings\Applic ation Data\Temporary Projects\Consol eApplication1\b in\Debug'
        updated cwd is 'C:\Documents and Settings\per\Lo cal Settings\Applic ation Data\Temporary Projects\Consol eApplication1'

        HTH,
        Per
        --
        Per Erik Strandberg

        Home: http://www.pererikstrandberg.se/blog/ .
        Optimization in C# and Visual Basic .NET: http://tomopt.com/tomnet/ .
        Last edited by PsychoCoder; Dec 14 '12, 07:04 PM.

        Comment

        • Rathorevivek
          New Member
          • Dec 2006
          • 17

          #5
          Originally posted by Bina
          Hi,
          I m new in c#.net . In C#.net, how i will get the current working path? when i used following function "Application.St artupPath" then it show the executable path.(e:\Projec t\DataList\bin\ debug). But i have created my project at the project directory. Now i want to get the path (e:\Project\Dat aList\). How i will get this? IS there any solution to solve this problem? I have created my crystal report file in the "e:\Project\Dat aList\" directory. How i will get the path when i will create installation file? Is there any solution to solve this problem? Please help me about this. Is there anybody who can help me?

          With regards
          Bina
          Hi Bina,
          Try out this
          Server.MapPath( Request.Applica tionPath + @''/your folder/");

          Regards,
          Vivek Rathore

          Comment

          • spriyasenthil
            New Member
            • Nov 2006
            • 9

            #6
            Originally posted by Bina
            Hi,
            I m new in c#.net . In C#.net, how i will get the current working path? when i used following function "Application.St artupPath" then it show the executable path.(e:\Projec t\DataList\bin\ debug). But i have created my project at the project directory. Now i want to get the path (e:\Project\Dat aList\). How i will get this? IS there any solution to solve this problem? I have created my crystal report file in the "e:\Project\Dat aList\" directory. How i will get the path when i will create installation file? Is there any solution to solve this problem? Please help me about this. Is there anybody who can help me?

            With regards
            Bina

            hi

            may be this will help u

            sPath = System.AppDomai n.CurrentDomain .BaseDirectory;

            or else

            sAppPath = Environment.Cur rentDirectory;

            try this out!

            Rdgs,
            Priya.S.

            Comment

            • varadeharsh108
              New Member
              • Dec 2012
              • 1

              #7
              Simply use (..) for parent directory ...

              i.e.
              string rptpath = Application.Sta rtupPath() + @"\..\..\";

              Comment

              Working...