User (Old forums)MemberDecember 20, 2006 at 4:09 amPost count: 23064
I get a System.Exception while copying files to an abstract folder. The file I want to copy has the “readonly” attribute. The exception will not be occured when I change this attribute. The exception occurs in line 4.
Here is my code:
1 //copy files and folders to a temporary folder
2 AbstractFolder af = new DiskFolder(sc.IncludeFilePath);
3 AbstractFolder taf = new DiskFolder(“TempFolder” + i.ToString());
4 af.CopyFilesTo(taf, sc.IncludeFileRecursive, true, sc.IncludeFileSearchPattern);
5 taf.CopyTo(m_ZipRoot, true);
Are there any ideas?
Imported from legacy forums. Posted by TJ (had 2665 views)User (Old forums)MemberDecember 20, 2006 at 3:09 pmPost count: 23064
Is it the file being copied that has the ReadOnly attribute, or the destination file (i.e. is there a file with the same name in the destination folder which has the ReadOnly attribute set to true)?
Can you provide the exception stack trace you are getting?
If it is on the destination file, this is normal because Windows will raise an exception on a ReadOnly file. What you need to do is to handle the FileSystemEvents.ItemException event, change the attribute on the destination file, and set e.Action to ItemExceptionAction.Retry. Then, if required, you can set back the ReadOnly property to true.
You can find more details from our online help documentation :
Imported from legacy forums. Posted by André (had 329 views)User (Old forums)MemberDecember 21, 2006 at 2:19 amPost count: 23064
that’s right, there is a destination file with the same name that has the ReadOnly attribute set to true. Normally at the destination there is not such a file.
The problem was that I have copied a file with the ReadOnly attribute set to true and after that I can’t delete the abstract folder.
Now I use this workaround:
After I have copied the file (files) I use a function to set the ReadOnly attribute at the destination to false. And so I have no longer the problem.
It’s a normaly Windows behavior when I copy a file, the attributes will also be copied.
Thanks a lot!
Imported from legacy forums. Posted by TJ (had 3713 views)
- You must be logged in to reply to this topic.