teenup
teenup

Reputation: 7667

Why does copying a file using FileInfo.CopyTo creates the destination copied file as readonly?

I have two folders in my asp.net web application in which I create new folders programmaticaly. The entire solution is under VSS source control.

I was not able to manipulate these two folders programmably. For that, I gave {MACHINE}\ASPNET user account full control over these two folders.

Still, the "access denied to the path" error was coming. I saw that these entire folders were marked readonly. I tried to uncheck Readonly from explorer but not successfull, readonly check does not get removed.

Also, if I copy files using method, the destinationn copied file becomes readonly. I have also tried File.SetAttributes(path,FileAttributes.Normal); but no success.

How can I make the copied file not READONLY ?

Upvotes: 1

Views: 2210

Answers (1)

Mantorok
Mantorok

Reputation: 5276

It is standard behaviour for copied files to carry over the attributes, and it should be possible to clear the ReadOnly attribute after you have copied it.

Does the SetAttributes call fail or does it appear to work? Ensure that the permissions are being inherited by the folder contents as well as the folders themselves.

EDIT: Just to add, you may need to give the IIS anonymous account read/write access to these folders as well, in IIS6 it is IUSR_machinename and in IIS7 it will be the IIS_USRS group.

Upvotes: 2

Related Questions