I have 10 zip files in a folder having path like this
TargetDirectory = "C:\docs\folder\"
some of the zip files names are like this
abc-19870908.Zip
abc-19870908.zip
abc-12345678.zip
and some are like this...
doc.zip
doc123.zip
..
I am getting all file names by using following code...
string [] fileEntries = Directory.GetFiles(targetDirectory);
foreach(string fileName in fileEntries)
{
// here I need to compare ,
// I mean I want to get only these files which are having
// these type of filenames `abc-19870908.Zip`
if (filename == "")
{
// I want to do something
}
}
What i have to put in the double quotes in this line if(filename == "")
to get like abc-19870908.Zip
these filenames.
Would any one please suggest any idea about this?
Many thanks...
If you're only interested in zip files containing a dash, you can provide a search pattern to Directory.GetFiles.
string [] fileEntries = Directory.GetFiles(targetDirectory, "*-*.zip");
Check out this link for more information on those search patterns: http://msdn.microsoft.com/en-us/library/wz42302f.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With