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