HI
I am creating the Zip file based on the Hierarchy.. So i am recrusively go throught the enteries and get the selected path and add the FIle under the Folder. my issue is how to retrive the selected path from the selectedEntries.
ZipEntry en = zip.SelectEntries(FileName).FirstOrDefault();
if the filename having space it is throwing argument null exception,
pls see the attached sample project. like that employee structureneed to create the folder,
can u update my project and send me..
thanks and regards
Kannan
Hi,
I couldn't quite catch what exactly you are trying to achieve from the provided sample. Here a few notes that might be of help:
ZipEntry en = zip.Entries.FirstOrDefault(e => e.FileName == FileName);
Regards
Thanks for reply. I need to get the path from the SelectedEntries. because of that i am passing the string Value in the method. i got the help from the previously mentioned link.. i could nt able to achive.
eg)
i am creating the File ..
ZipEntry entry= ZipEntry.CreateFile(item.ExportTitle + ".jpg", FullParentPath, image.ToStream());
zip.Entries.Add(entry);
then i need to add the Folder below file.so i am using
ZipEntry en = zip.SelectEntries(FullParentPath).FirstOrDefault();
here not return the particular path.. can u provide one simple project to get the paricular file in any levell .. this one how to form the String.
thanks
kan
i didnt get the solution.. if the Folder name Having Spaces i didntable to retrive the Path..
pls provide some samples .. very urgent.
Thanks
Thanks for Ur help.
i was tried what u mentioned but still not working. While Creating Directory
ZipEntry entrys = ZipEntry.CreateDirectory(emps.FullName);
now i checked it is ends with this "\\ "
for file "/" i am not not able to retrieve the Path..
i tried lot not able to retive the path if have any space in the FileName. some of my FolderName having Space me pasding the string as Path.. it returns null .
Pls can u provide one simple Example to recursively retrieve the path and Created Folder or file inside.
Hi Kan,
as far as I understood you you just need to extract the directory path from entry's FilePath. Basically your CreateZipFile method should look somthing like this:
public void CreateZipFile(ZipFile zip, EmploYeeHierarchy emps,string FileName){ foreach (var item in emps.empHierarchy) { ZipEntry en = zip.Entries.FirstOrDefault(e => e.FileName == FileName); //Extract the path to the holding directory int lastIndex = en.FileName.LastIndexOf('/'); string path = en.FileName.Substring(0, lastIndex); ZipEntry entry = ZipEntry.CreateFile(emps.ID + ".txt", path, "n77tr65r65"); zip.Entries.Add(entry); var childFullPath = FileName + item.FullName.Trim(); CreateZipFile(zip,item,"'" + childFullPath + "'"); }}Hope this helps.
I am creating the Folder inside only creating File. because of that only need to retive the Folder not a file.. if the Folder name having space not taking properly...