User (Old forums)MemberNovember 30, 2010 at 2:10 pmPost count: 23064
I am trying to figure out how to do the following. I need to unzip a file into a directory. If the ZIP file has been saved with folder files inside folders, I need to ignore all of the paths. As each file is extracted from the zip, I need to save it with a name of my choosing.
For example, if there was a ZIP file saved with these 3 files with these original paths:
I want to write out the 3 files to C:\NewDir without any subdirectories and with new names like this:
Thanks in advance for your help.
Imported from legacy forums. Posted by Robert (had 1767 views)User (Old forums)MemberNovember 30, 2010 at 2:19 pmPost count: 23064
I should also state that I am using C#. Thanks!
Imported from legacy forums. Posted by Robert (had 245 views)User (Old forums)MemberDecember 1, 2010 at 9:15 amPost count: 23064
I figured out how to change the names of the files within the zip. I did it like this:
AbstractFile  fileList = zip.GetFiles(true, fileMask);
int numFileInZip = fileList.Length;
for (int current = 0 ; current < numFileInZip; current++)
fileList[current].Name = “newname” + current.ToString(); // just a rough example.
I am still trying to figure out how to unzip into a single folder, removing any subdirectories.
Imported from legacy forums. Posted by Robert (had 246 views)Xceed SupportMemberDecember 1, 2010 at 1:31 pmPost count: 5658
I have tried this on my machine, and it would work if you create a recursive method over the folders and moving all files to one location.
Here’s a code snippet :
public void RecursiveMoveFiles(AbstractFolder From, AbstractFolder To)
foreach (FileSystemItem childItem in From.GetItems(false))
if( typeof(DiskFolder) == childItem.GetType())
var f = (AbstractFolder)childItem;
childItem.Name = name.ToString() + “.txt”;
This should solve the problem 🙂
Imported from legacy forums. Posted by Michel [Xceed] (had 1359 views)
- You must be logged in to reply to this topic.