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. Windows 7 and Directory.Exists ???

Windows 7 and Directory.Exists ???

Scheduled Pinned Locked Moved C#
questiondiscussion
5 Posts 4 Posters 2 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.
  • P Offline
    P Offline
    Paul Brower
    wrote on last edited by
    #1

    I have the following lines of code (2.0 framework) that worked in Win XP, but doesn't work with Windows 7: if (!Directory.Exists(@"c:\Program Files\Newsham\PigtrakDesktop\RAPI")) { Directory.CreateDirectory(@"c:\Program Files\Newsham\PigtrakDesktop\RAPI"); } Here's the weird part: If I try to navigate to c:\Program Files\Newsham\PigtrakDesktop using the Windows 7 explorer, the RAPI directory is NOT there. However, in my code, if tell it to list the files in the same directory, there ARE FILES THERE! This is really killing me. Any thoughts?

    P 1 Reply Last reply
    0
    • P Paul Brower

      I have the following lines of code (2.0 framework) that worked in Win XP, but doesn't work with Windows 7: if (!Directory.Exists(@"c:\Program Files\Newsham\PigtrakDesktop\RAPI")) { Directory.CreateDirectory(@"c:\Program Files\Newsham\PigtrakDesktop\RAPI"); } Here's the weird part: If I try to navigate to c:\Program Files\Newsham\PigtrakDesktop using the Windows 7 explorer, the RAPI directory is NOT there. However, in my code, if tell it to list the files in the same directory, there ARE FILES THERE! This is really killing me. Any thoughts?

      P Offline
      P Offline
      Paul Brower
      wrote on last edited by
      #2

      I can't explain WHY the **** this is like this, but I found my files. They are located at: C:\Users\pbrower\AppData\Local\VirtualStore\Program Files\Newsham\PigtrakDesktop What the hell?

      C D 2 Replies Last reply
      0
      • P Paul Brower

        I can't explain WHY the **** this is like this, but I found my files. They are located at: C:\Users\pbrower\AppData\Local\VirtualStore\Program Files\Newsham\PigtrakDesktop What the hell?

        C Offline
        C Offline
        Calla
        wrote on last edited by
        #3

        Maybe something to do with MS not being so keen on us writing (and adding directories) to the Program Files folder in Vista and Windows 7? Just a thought (on friday afternoon)... :)

        1 Reply Last reply
        0
        • P Paul Brower

          I can't explain WHY the **** this is like this, but I found my files. They are located at: C:\Users\pbrower\AppData\Local\VirtualStore\Program Files\Newsham\PigtrakDesktop What the hell?

          D Offline
          D Offline
          Daniel Grunwald
          wrote on last edited by
          #4

          "C:\Program Files" is not writable for standard users (just as it was since Win2000 and earlier). Starting with Vista, the default user account is a standard user; getting admin rights only when you explicitly run an app with them (UAC). To allow old programs to continue to run, Windows will redirect writes to the "VirtualStore". This is done only with programs that are not marked as "UAC-compatible". So you have to do two things: 1) to avoid confusion due to file system virtualization; mark your program as UAC-compatible by embedding an UAC manifest. VS2008 should do this automatically (see "Application Manifest" in the project options); for VS2005 it's a little bit more complicated: http://blogs.msdn.com/shawnfa/archive/2006/04/06/568563.aspx[^] 2) Don't write to Program Files.

          realJSOPR 1 Reply Last reply
          0
          • D Daniel Grunwald

            "C:\Program Files" is not writable for standard users (just as it was since Win2000 and earlier). Starting with Vista, the default user account is a standard user; getting admin rights only when you explicitly run an app with them (UAC). To allow old programs to continue to run, Windows will redirect writes to the "VirtualStore". This is done only with programs that are not marked as "UAC-compatible". So you have to do two things: 1) to avoid confusion due to file system virtualization; mark your program as UAC-compatible by embedding an UAC manifest. VS2008 should do this automatically (see "Application Manifest" in the project options); for VS2005 it's a little bit more complicated: http://blogs.msdn.com/shawnfa/archive/2006/04/06/568563.aspx[^] 2) Don't write to Program Files.

            realJSOPR Offline
            realJSOPR Offline
            realJSOP
            wrote on last edited by
            #5

            More specifically, don't write anywhere but the AppData folder.

            .45 ACP - because shooting twice is just silly
            -----
            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
            -----
            "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

            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