Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET System.Exception while copying files to an abstract folder

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #19714 |

    Hi,

    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);
    6 taf.Delete();

    Are there any ideas?

    Thanx

    Imported from legacy forums. Posted by TJ (had 2665 views)

    User (Old forums)
    Member
    Post 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 :

    <a href=”http://doc.xceedsoft.com/products/FileSystemCore/ref/xceed.filesystem.filesystemevents.itemexception.html”>http://doc.xceedsoft.com/products/FileSystemCore/ref/xceed.filesystem.filesystemevents.itemexception.html</a&gt;
    <a href=”http://doc.xceedsoft.com/products/FileSystemCore/ref/xceed.filesystem.itemexceptionaction.html”>http://doc.xceedsoft.com/products/FileSystemCore/ref/xceed.filesystem.itemexceptionaction.html</a&gt;

    Imported from legacy forums. Posted by André (had 329 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi,

    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)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.