This request with one instruction says neatly, "Give me a list of the bare file name for which the file is a ZIP repository containing a specific file structure."
But I use both the .Where () extension method (free syntax) and the select request, because everything I try to execute cannot be compiled. If I change ".Where (file ==> <statement>)" to "where <statement>", I get an error that the anonymous method code does not return bool, and if I change "select <item>" to " . Select (<clause>) ", error:" No select clause is used. "
I am satisfied with either the request or the free syntax, but I would like to dwell on this or that. Can someone explain why this does not work and what I need to do to set up one consistent syntax?
return (from file in Directory.EnumerateFiles(
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), Globals.CompanyName, ProjectName, FolderName),
imageExtension,
SearchOption.TopDirectoryOnly)
.Where(file =>
{
try
{
string relativePath = ClassFru.Station + "/";
var zip = new ZipFile();
zip.ZipError += (s, o) => { throw new Exception(); };
using (zip = ZipFile.Read(file))
{
foreach (var fru in this.gFrus)
{
var fruPath = relativePath + fru.Id + '.';
if (!(from e in zip where !e.IsDirectory && e.FileName.StartsWith(fruPath) select true).Any()) { return false; }
}
return true;
}
}
catch (Exception)
{
return false;
}
})
select Path.GetFileNameWithoutExtension(file)).ToArray();
shipr source
share