Click here to Skip to main content
15,909,498 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I want to search .zip files from project folder.

code

C#
string _sourceFile = System.Web.HttpContext.Current.Server.MapPath("~/uploadFiles");

            string[] s2 = Directory.GetDirectories(_sourceFile, "*.zip", SearchOption.AllDirectories);


but zip file not searched.

Please help me.

Thanks

What I have tried:

i want to try search zip files from project folder.
Please help me.
Thanks
Posted
Updated 18-Jun-16 3:30am
Comments
Sergey Alexandrovich Kryukov 18-Jun-16 14:07pm    
Do you want to find, 1) some zip files, 2) some files packed in zip files, 3) some content of the files packed in zip files?
There are three levels, and you are not getting in any of them, you are searching for directories, not even files. You are going to find all directories with the name ending with ".zip". Do you really have such directories?
—SA
Ram jha 18-Jun-16 14:21pm    
hi,
i want to find all .zip files from my project folder.
please help me.
Thanks

1 solution

You're not "searching" zip files. That line of code returns all of the directories under the _sourceFile path in the filesystem.

ZIP files are NOT part of the filesystem and so will not be considered part of the directory structure. In order to get the folders inide the ZIP you have to treat it as a ZIP file and use methods that are appropriate for searching inside of a ZIP and extracting the files/folders in it.
 
Share this answer
 
Comments
Ram jha 18-Jun-16 11:50am    
Dear sir,
I request you how to search zip file from directory(project folder).
Dave Kreskowiak 18-Jun-16 12:13pm    
What do you mean "search"? What are you trying to get out of the ZIP file?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900