Error while Extracting Files in zip folder
-
i am using below code to extract the files inside the zip folder. getting an error while using copyHere method .. after deleteing the folder i m trying to create a new one . and then copying from the zip file but still it gives an error "File exist" Please provide a solution thanks in advance
if (Directory.Exists(unzipFilePath))
{
Directory.Delete(unzipFilePath, true);
Directory.CreateDirectory(unzipFilePath);
}
else
{
Directory.CreateDirectory(unzipFilePath);
}
Shell objShell = new Shell();
Folder shellZipFile = objShell.NameSpace(zipFilePath);
Folder shellUnZipFile = objShell.NameSpace(uzipFilePath);
foreach (FolderItem zipFileitem in shellZipFile.Items())
{
shellUnZipFile.CopyHere(zipFileitem, 0);//File exist error is thrown from shell
}This error is happening in a particular system
-
i am using below code to extract the files inside the zip folder. getting an error while using copyHere method .. after deleteing the folder i m trying to create a new one . and then copying from the zip file but still it gives an error "File exist" Please provide a solution thanks in advance
if (Directory.Exists(unzipFilePath))
{
Directory.Delete(unzipFilePath, true);
Directory.CreateDirectory(unzipFilePath);
}
else
{
Directory.CreateDirectory(unzipFilePath);
}
Shell objShell = new Shell();
Folder shellZipFile = objShell.NameSpace(zipFilePath);
Folder shellUnZipFile = objShell.NameSpace(uzipFilePath);
foreach (FolderItem zipFileitem in shellZipFile.Items())
{
shellUnZipFile.CopyHere(zipFileitem, 0);//File exist error is thrown from shell
}This error is happening in a particular system
It seems a little confusing even looking at the MSDN documentation: http://msdn.microsoft.com/en-us/library/aa328748(v=VS.71).aspx[^] which says that
true
will delete files and subdirectories. However, when you look at the example on the same page it says:'This operation will not be allowed because there are subdirectories.
for the VB example, and
// This will succeed because subdirectories are being deleted
for the C#. I suggest you write a quick-and-dirty tester to check if the directory deleted exists after the delete, and if so what it contains. I suspect that the VB example may be correct, and you will have to manually delete files and subdirectories.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
-
It seems a little confusing even looking at the MSDN documentation: http://msdn.microsoft.com/en-us/library/aa328748(v=VS.71).aspx[^] which says that
true
will delete files and subdirectories. However, when you look at the example on the same page it says:'This operation will not be allowed because there are subdirectories.
for the VB example, and
// This will succeed because subdirectories are being deleted
for the C#. I suggest you write a quick-and-dirty tester to check if the directory deleted exists after the delete, and if so what it contains. I suspect that the VB example may be correct, and you will have to manually delete files and subdirectories.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Thanks for the reply phiscally i checked the folder it was wmpty and then i inserted below code in copy..
if (File.Exists(String.Format(@"{0}\{1}",unzipFolderName,zipFileitem.Name)))
{
File.Delete(String.Format(@"{0}\{1}",unzipFolderName, zipFileitem.Name));
}
shellUnZipFile.CopyHere(zipFileitem, 0); // still it throwd error -
Thanks for the reply phiscally i checked the folder it was wmpty and then i inserted below code in copy..
if (File.Exists(String.Format(@"{0}\{1}",unzipFolderName,zipFileitem.Name)))
{
File.Delete(String.Format(@"{0}\{1}",unzipFolderName, zipFileitem.Name));
}
shellUnZipFile.CopyHere(zipFileitem, 0); // still it throwd errorDon't check using Explorer - check if it still exists after the delete in your code, and before you do anything else. (Remember that windows can have invisible files, and hidden files which won't show up in Explorer).
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
-
Don't check using Explorer - check if it still exists after the delete in your code, and before you do anything else. (Remember that windows can have invisible files, and hidden files which won't show up in Explorer).
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
I had checked through code, explorer by making files visible and all those stuff.. :( and one more thing in this specific computer.i tried something manually.. like i right clicked the zip file and selected explore. i got an option to copy the file But when i paste it paste is not happening.
-
I had checked through code, explorer by making files visible and all those stuff.. :( and one more thing in this specific computer.i tried something manually.. like i right clicked the zip file and selected explore. i got an option to copy the file But when i paste it paste is not happening.
Have you checked the folder permissions?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
-
Have you checked the folder permissions?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.