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. File Problem in VISTA

File Problem in VISTA

Scheduled Pinned Locked Moved C#
help
8 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.
  • W Offline
    W Offline
    Wamuti
    wrote on last edited by
    #1

    I want to move a file with the following function but i get UnathorizedAccessException thrown. What could be the problem. When i try to move it to My Documents, it works just fine, only when i move it to the C Drive it throws the Exception mentioned. I'm really stuck.

    private void MoveFile()
    {
    string fileName = "myFile.txt";
    FileInfo fInfo = new FileInfo(fileName);
    fInfo.MoveTo(@"C:\"+fileName);
    MessageBox.Show("Done");
    }

    Wamuti: Any man can be an island, but islands to need water around them! Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.

    R realJSOPR 2 Replies Last reply
    0
    • W Wamuti

      I want to move a file with the following function but i get UnathorizedAccessException thrown. What could be the problem. When i try to move it to My Documents, it works just fine, only when i move it to the C Drive it throws the Exception mentioned. I'm really stuck.

      private void MoveFile()
      {
      string fileName = "myFile.txt";
      FileInfo fInfo = new FileInfo(fileName);
      fInfo.MoveTo(@"C:\"+fileName);
      MessageBox.Show("Done");
      }

      Wamuti: Any man can be an island, but islands to need water around them! Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.

      R Offline
      R Offline
      Rob Philpott
      wrote on last edited by
      #2

      Have you got Admin rights on the box? Sounds pretty much to me like you don't have access to c:\ Can you manually move a file there in explorer?

      Regards, Rob Philpott.

      W 1 Reply Last reply
      0
      • R Rob Philpott

        Have you got Admin rights on the box? Sounds pretty much to me like you don't have access to c:\ Can you manually move a file there in explorer?

        Regards, Rob Philpott.

        W Offline
        W Offline
        Wamuti
        wrote on last edited by
        #3

        When i move a file in C, i get a pop up saying Destination Folder Access Denied, then asks me to provide administrators permission. I click on Continue to get permission. Then i get permission and the file is moved. Is there a way my program can make such permission requests? What is the best way to go about this?

        Wamuti: Any man can be an island, but islands to need water around them! Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.

        R 1 Reply Last reply
        0
        • W Wamuti

          When i move a file in C, i get a pop up saying Destination Folder Access Denied, then asks me to provide administrators permission. I click on Continue to get permission. Then i get permission and the file is moved. Is there a way my program can make such permission requests? What is the best way to go about this?

          Wamuti: Any man can be an island, but islands to need water around them! Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.

          R Offline
          R Offline
          Rob Philpott
          wrote on last edited by
          #4

          Well, security isn't really my thing, but your problem is clear enough. First off, can you move the file somewhere other than root? If not, you can fiddle around with the folder security on it and make sure the account you're using has full access to it. And, if its that stupid UAC vista thing, I'd consider turning it off completely if you can. It's most annoying.

          Regards, Rob Philpott.

          W 1 Reply Last reply
          0
          • R Rob Philpott

            Well, security isn't really my thing, but your problem is clear enough. First off, can you move the file somewhere other than root? If not, you can fiddle around with the folder security on it and make sure the account you're using has full access to it. And, if its that stupid UAC vista thing, I'd consider turning it off completely if you can. It's most annoying.

            Regards, Rob Philpott.

            W Offline
            W Offline
            Wamuti
            wrote on last edited by
            #5

            I think i have to deal with UAC :doh: !! Thanks :thumbsup:

            Wamuti: Any man can be an island, but islands to need water around them! Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.

            1 Reply Last reply
            0
            • W Wamuti

              I want to move a file with the following function but i get UnathorizedAccessException thrown. What could be the problem. When i try to move it to My Documents, it works just fine, only when i move it to the C Drive it throws the Exception mentioned. I'm really stuck.

              private void MoveFile()
              {
              string fileName = "myFile.txt";
              FileInfo fInfo = new FileInfo(fileName);
              fInfo.MoveTo(@"C:\"+fileName);
              MessageBox.Show("Done");
              }

              Wamuti: Any man can be an island, but islands to need water around them! Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.

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

              You can't copy anything to the C drive unless it's to the application data 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

              S 1 Reply Last reply
              0
              • realJSOPR realJSOP

                You can't copy anything to the C drive unless it's to the application data 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

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

                Its all because of UAC, google to run application as Administrator, vista will ask for the permission. Actually, you are supposed to use the personal folder(My documents/App folder), in that case you will not face such problem.

                realJSOPR 1 Reply Last reply
                0
                • S Sipder

                  Its all because of UAC, google to run application as Administrator, vista will ask for the permission. Actually, you are supposed to use the personal folder(My documents/App folder), in that case you will not face such problem.

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

                  I said that, but in a lot fewer words.

                  .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