User (Old forums)MemberJune 28, 2011 at 10:49 amPost count: 23064
I use Xceed.Zip and try to compress a folder to zip-file as follows:
private void CompressTo(string fileName)
var temp = new DiskFolder(TempFolder);
var zip = new ZipArchive(new DiskFile(fileName));
temp.CopyFilesTo(zip, true, true);
When i try temp.Delete(), i have Xceed.FileSystem.ItemIsReadOnlyException:
Cannot perform the requested operation on an item that has the read-only attribute.
at Xceed.FileSystem.DiskFile.DoDelete(FileSystemEventsSession session)
at Xceed.FileSystem.FileSystemItem.ListDeleteCore(FileSystemEventsSession session, ItemPair currentItemPair)
at Xceed.FileSystem.FileSystemItem.ListDelete(FileSystemEventsSession session)
at Xceed.FileSystem.FileSystemItem.Delete(FileSystemEvents events, Object userData)
at iBwave.Mobile.Common.ZipSerializer.CompressTo(String fileName) in D:\Source\IBLIB\trunk\Internal\InternalProjects\iBwave.Mobile.Common\ZipSerializer.cs:line 160
at iBwave.Mobile.Common.ZipSerializer.Export(Project project, String fileName, Exception& ex) in D:\Source\IBLIB\trunk\Internal\InternalProjects\iBwave.Mobile.Common\ZipSerializer.cs:line 135
Also, if i don’t call DiskFolder.Delete() but instead try to delete my temp folder, i have pretty the same exception.
It is a bit surprising since i thought that CopyFilesTo method is synchronous, but looks like it isn’t.
Is there any way to wait for compress operation is completed, or delete the folder in some other way?
Imported from legacy forums. Posted by Dmitry (had 1515 views)Xceed SupportMemberJune 29, 2011 at 3:29 pmPost count: 5658
I know that we resolved this issue yesterday, but I will post this answer in case another developer is looking for the solution
If the folder and its child items are ReadOnly, you must change its
Attributes to Normal so that you may Delete them. To do so, you must run
your Delete on the DiskFolder. Then, you must trap the error in a
Try/Catch and in the Catch, you must change the attributes for the
folder and its children.
I would suggest creating your own Delete() so that it does not make your code messy. For example:
Public Sub DeleteMyFolderAndItsChildren()
Catch ex As Exception
‘Set the Attributes to the DiskFolder
temp.Attributes = IO.FileAttributes.Normal
‘Apply the Attributes to the DiskFolder
‘Change the attributes for the Children
‘You must call the Delete() again without error
You must then call the function that will change the Attributes for all child items so that they are not ReadOnly. For example:
Public Sub ChangeAttributes(ByVal folder As DiskFolder)
For Each childItem As FileSystemItem In folder.GetItems(True)
childItem.Attributes = IO.FileAttributes.Normal
Imported from legacy forums. Posted by Marc [Xceed] (had 1121 views)User (Old forums)MemberApril 2, 2015 at 8:43 amPost count: 23064
But If i want to delete a zip file wrong zipped that it is being used yet because that zipping process was not finiched, how can i do?
Imported from legacy forums. Posted by Francisco (had 143 views)
- You must be logged in to reply to this topic.