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. reading reodonly files for backup (Steams)

reading reodonly files for backup (Steams)

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

    Hi all, I have to backup some files, some with readonly attrib. Is there an other way to open the files with readonly attribute than to reset the "r" attribute, reading and re-setting the attribute again ? tnx Frank

    C 1 Reply Last reply
    0
    • F fracalifa

      Hi all, I have to backup some files, some with readonly attrib. Is there an other way to open the files with readonly attribute than to reset the "r" attribute, reading and re-setting the attribute again ? tnx Frank

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Yes, write code that only asks for read access, then you won't have any problems. I believe I found recently that some .NET libraries ask for full access even if you ask for read only, so I would try using a different class to do what you want, or just use File.Copy to copy the file to the new location.

      Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )

      F 1 Reply Last reply
      0
      • C Christian Graus

        Yes, write code that only asks for read access, then you won't have any problems. I believe I found recently that some .NET libraries ask for full access even if you ask for read only, so I would try using a different class to do what you want, or just use File.Copy to copy the file to the new location.

        Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )

        F Offline
        F Offline
        fracalifa
        wrote on last edited by
        #3

        Thank you, no can't use copy due to store the files in a database ... Frank

        C 1 Reply Last reply
        0
        • F fracalifa

          Thank you, no can't use copy due to store the files in a database ... Frank

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Oh, I didn't get they were going into a DB. Well, then change the code you use to read the file. I think File.ReadAllBytes works fine, but using streams does not work, from memory. It's a bug in the framework, essentially.

          Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )

          L 1 Reply Last reply
          0
          • C Christian Graus

            Oh, I didn't get they were going into a DB. Well, then change the code you use to read the file. I think File.ReadAllBytes works fine, but using streams does not work, from memory. It's a bug in the framework, essentially.

            Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            Christian Graus wrote:

            using streams does not work ... It's a bug in the framework, essentially.

            I disagree. Creating a Stream from a path, without specifying the intended access, assumes read/write intentions. What else should the framework do? :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in


            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