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. Creating a file and saving it to C

Creating a file and saving it to C

Scheduled Pinned Locked Moved C#
securityhelpquestion
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.
  • D Offline
    D Offline
    Darrall
    wrote on last edited by
    #1

    I am trying to create a simple text file and save it to C as: File.Create(C:/Points.txt) I am getting this error: System.UnauthorizedAccessException was unhandled Message="Access to the path 'C:\\Points.txt' is denied." Source="mscorlib" StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, etc. Can anyone tell me why? Its my computer and I am the sole user and administrator. Thanks

    S L P 3 Replies Last reply
    0
    • D Darrall

      I am trying to create a simple text file and save it to C as: File.Create(C:/Points.txt) I am getting this error: System.UnauthorizedAccessException was unhandled Message="Access to the path 'C:\\Points.txt' is denied." Source="mscorlib" StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, etc. Can anyone tell me why? Its my computer and I am the sole user and administrator. Thanks

      S Offline
      S Offline
      Super Lloyd
      wrote on last edited by
      #2

      Interesting, I tried and got the same error. Then I tried with Notepad and I got the same error as well. Seems to be one of those path were you need to be really the administrator (as in, if you said yes to an UAC prompt)

      A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.

      1 Reply Last reply
      0
      • D Darrall

        I am trying to create a simple text file and save it to C as: File.Create(C:/Points.txt) I am getting this error: System.UnauthorizedAccessException was unhandled Message="Access to the path 'C:\\Points.txt' is denied." Source="mscorlib" StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, etc. Can anyone tell me why? Its my computer and I am the sole user and administrator. Thanks

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

        I had absolutely no trouble doing this on XP, not even a warning. So I guess you're not using XP

        D 1 Reply Last reply
        0
        • D Darrall

          I am trying to create a simple text file and save it to C as: File.Create(C:/Points.txt) I am getting this error: System.UnauthorizedAccessException was unhandled Message="Access to the path 'C:\\Points.txt' is denied." Source="mscorlib" StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, etc. Can anyone tell me why? Its my computer and I am the sole user and administrator. Thanks

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          Vista doesn't allow writing to the root directory; get a better operating system (XP). Better yet, store application data in the application data directory.

          D 1 Reply Last reply
          0
          • L Lost User

            I had absolutely no trouble doing this on XP, not even a warning. So I guess you're not using XP

            D Offline
            D Offline
            Darrall
            wrote on last edited by
            #5

            No...Windows7

            D 1 Reply Last reply
            0
            • P PIEBALDconsult

              Vista doesn't allow writing to the root directory; get a better operating system (XP). Better yet, store application data in the application data directory.

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

              Trouble with storing in the application directory is then you have to have the user browse to where he stored the application so you can pick up the path. Better than random locations on C I suppose.

              P 1 Reply Last reply
              0
              • D Darrall

                Trouble with storing in the application directory is then you have to have the user browse to where he stored the application so you can pick up the path. Better than random locations on C I suppose.

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #7

                The application data directory.

                1 Reply Last reply
                0
                • D Darrall

                  No...Windows7

                  D Offline
                  D Offline
                  Dan Mos
                  wrote on last edited by
                  #8

                  Hy, 3 options: 0) Disable the UAC or play with it until W7 will let you copy on root(c:\) without the UAC prompt. 1) Implement a UAC like button or something for this purpose Here's an example on how to bypass the UAC 2) Use the application folder I highly recommed nr 2)

                  modified on Tuesday, April 6, 2010 10:56 PM

                  D 1 Reply Last reply
                  0
                  • D Dan Mos

                    Hy, 3 options: 0) Disable the UAC or play with it until W7 will let you copy on root(c:\) without the UAC prompt. 1) Implement a UAC like button or something for this purpose Here's an example on how to bypass the UAC 2) Use the application folder I highly recommed nr 2)

                    modified on Tuesday, April 6, 2010 10:56 PM

                    D Offline
                    D Offline
                    Darrall
                    wrote on last edited by
                    #9

                    Thanks :)

                    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