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 / C++ / MFC
  4. How to judge if the folder can be written?

How to judge if the folder can be written?

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminjsonhelptutorialquestion
4 Posts 2 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.
  • S Offline
    S Offline
    Syouki_kou
    wrote on last edited by
    #1

    How could I judge it, it assume that I have a path like C:\My folder\Myfile\, how to judge if this folder can be written? Note, path may be on a read-only CD or from network with no write privilege, is there a API to complete this function? I tried CreateFile, while it fail with the error code ERROR_ACCESS_DENIED it is have no write privilege, what I want to know is that if there are other methods to do so? 3ks and best regards.

    One day a pretty girl asked me:"Do u think you are handsome?" "I don't think so!".She gave a slap in my face:"Why lying?"...

    M 1 Reply Last reply
    0
    • S Syouki_kou

      How could I judge it, it assume that I have a path like C:\My folder\Myfile\, how to judge if this folder can be written? Note, path may be on a read-only CD or from network with no write privilege, is there a API to complete this function? I tried CreateFile, while it fail with the error code ERROR_ACCESS_DENIED it is have no write privilege, what I want to know is that if there are other methods to do so? 3ks and best regards.

      One day a pretty girl asked me:"Do u think you are handsome?" "I don't think so!".She gave a slap in my face:"Why lying?"...

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      How about the GetFileAttributes()[^] API? Mark

      "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

      S 1 Reply Last reply
      0
      • M Mark Salsbery

        How about the GetFileAttributes()[^] API? Mark

        "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

        S Offline
        S Offline
        Syouki_kou
        wrote on last edited by
        #3

        GetFileAttributes?? I don't think it can work properly. Here I have a path, GetFileAttributes can only get its attribute, how could i know if i can write in the folder. Even the folder is read-only, I can create file in it, right?

        One day a pretty girl asked me:"Do u think you are handsome?" "I don't think so!".She gave a slap in my face:"Why lying?"...

        M 1 Reply Last reply
        0
        • S Syouki_kou

          GetFileAttributes?? I don't think it can work properly. Here I have a path, GetFileAttributes can only get its attribute, how could i know if i can write in the folder. Even the folder is read-only, I can create file in it, right?

          One day a pretty girl asked me:"Do u think you are handsome?" "I don't think so!".She gave a slap in my face:"Why lying?"...

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          :doh: Oh yeah, sorry :) It seems like checking all the possibilities (security, writable device, etc) would be alot more work than just checking the return from CreateFile(). Maybe there's an easier API - I don't know what it is. Mark

          "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

          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