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. General Programming
  3. C#
  4. How can we find windows Temp folder ?

How can we find windows Temp folder ?

Scheduled Pinned Locked Moved C#
csharpquestion
7 Posts 4 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.
  • M Offline
    M Offline
    Mohammad Dayyan
    wrote on last edited by
    #1

    Hey guys. How can we find windows Temp folder in c# ? Like this :

    C:\Documents and Settings\Mds\Local Settings\Temp

    Thanks in advance.

    M G D 3 Replies Last reply
    0
    • M Mohammad Dayyan

      Hey guys. How can we find windows Temp folder in c# ? Like this :

      C:\Documents and Settings\Mds\Local Settings\Temp

      Thanks in advance.

      M Offline
      M Offline
      M Harris
      wrote on last edited by
      #2

      System.IO.Path.GetTempPath() should about do it :)

      -- Real programmers don't comment their code. It was hard to write, it should be hard to understand.

      1 Reply Last reply
      0
      • M Mohammad Dayyan

        Hey guys. How can we find windows Temp folder in c# ? Like this :

        C:\Documents and Settings\Mds\Local Settings\Temp

        Thanks in advance.

        G Offline
        G Offline
        Giorgi Dalakishvili
        wrote on last edited by
        #3

        Here you are: Environment.GetEnvironmentVariable Method[^]

        Giorgi Dalakishvili #region signature my articles #endregion

        1 Reply Last reply
        0
        • M Mohammad Dayyan

          Hey guys. How can we find windows Temp folder in c# ? Like this :

          C:\Documents and Settings\Mds\Local Settings\Temp

          Thanks in advance.

          D Offline
          D Offline
          DaveyM69
          wrote on last edited by
          #4

          The previous answer is correct and is what I use but (for the sake of completeness) there's also Environment.GetEnvironmentVariable("TEMP"); or Environment.GetEnvironmentVariable("TMP"); Didn't see Giorgi's answer till after posting as it was on the next page!

          Dave
          BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
          Expect everything to be hard and then enjoy the things that come easy. (code-frog)

          M 1 Reply Last reply
          0
          • D DaveyM69

            The previous answer is correct and is what I use but (for the sake of completeness) there's also Environment.GetEnvironmentVariable("TEMP"); or Environment.GetEnvironmentVariable("TMP"); Didn't see Giorgi's answer till after posting as it was on the next page!

            Dave
            BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
            Expect everything to be hard and then enjoy the things that come easy. (code-frog)

            M Offline
            M Offline
            Mohammad Dayyan
            wrote on last edited by
            #5

            Thanks a lot DaveyM69. But I want to know is this correct :

            Environment.GetEnvironmentVariable("temp");

            D 1 Reply Last reply
            0
            • M Mohammad Dayyan

              Thanks a lot DaveyM69. But I want to know is this correct :

              Environment.GetEnvironmentVariable("temp");

              D Offline
              D Offline
              DaveyM69
              wrote on last edited by
              #6

              It works (tried on XP Pro SP3) so I guess the string parameter isn't case sensitive. They are saved however in upper case so it would be safer to pass it that way. You can see all the variables by opening control panel and selecting System (or right click My Computer and chose properties). On the Advanced tab click the Environment Variables button.

              Dave
              BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
              Expect everything to be hard and then enjoy the things that come easy. (code-frog)

              M 1 Reply Last reply
              0
              • D DaveyM69

                It works (tried on XP Pro SP3) so I guess the string parameter isn't case sensitive. They are saved however in upper case so it would be safer to pass it that way. You can see all the variables by opening control panel and selecting System (or right click My Computer and chose properties). On the Advanced tab click the Environment Variables button.

                Dave
                BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
                Expect everything to be hard and then enjoy the things that come easy. (code-frog)

                M Offline
                M Offline
                Mohammad Dayyan
                wrote on last edited by
                #7

                Thank you very much DaveyM69.

                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