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. Unset ReadOnly? (Basic BitWise Question!)

Unset ReadOnly? (Basic BitWise Question!)

Scheduled Pinned Locked Moved C#
question
3 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.
  • M Offline
    M Offline
    MartinSmith
    wrote on last edited by
    #1

    Hi. I am trying to leave all the other attributes of a file alone but unset read only. I am trying File.SetAttributes(strFileToStreamPath, File.GetAttributes(strFileToStreamPath) ^ FileAttributes.ReadOnly); which works fine if the file is read only but not if it isn't (it makes it read only!) How do I do a "OR NOT" sort of thing. I can't see any examples of this in the documentation? Cheers, Martin

    L 1 Reply Last reply
    0
    • M MartinSmith

      Hi. I am trying to leave all the other attributes of a file alone but unset read only. I am trying File.SetAttributes(strFileToStreamPath, File.GetAttributes(strFileToStreamPath) ^ FileAttributes.ReadOnly); which works fine if the file is read only but not if it isn't (it makes it read only!) How do I do a "OR NOT" sort of thing. I can't see any examples of this in the documentation? Cheers, Martin

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

      Have you tried &~ ? The the bitwise "AND NOT" operator. regards

      M 1 Reply Last reply
      0
      • L Lost User

        Have you tried &~ ? The the bitwise "AND NOT" operator. regards

        M Offline
        M Offline
        MartinSmith
        wrote on last edited by
        #3

        Thank You! I've just tried it and that works great!

        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