我正在尝试迭代 sting[] 并仅获取符合条件“包含”的记录。
我一直在尝试这个:
var lines = File.ReadAllLines("C:\\temp\\" + ReportPushFile("fileToSend_1.txt")).Where(i => i.Contains("BILL"));
但这会再次返回我所有记录,而无需过滤。怎么了?
class Program : Logger
{
public static FTPclient Ftp = new FTPclient("ftp://smsftp.mobyt.it/", "C17053_004", "i7z0dx5b");
static void Main(string[] args)
{
List<Sms> sms = new List<Sms>();
sms.Add(new Sms() { recipient = "+393664528452" });
var lines = File.ReadAllLines("C:\\temp\\" + ReportPushFile("fileToSend_1.txt")).Where(i => i.StartsWith("BILL"));
// ...
}
public static string ReportPushFile(string NomeFile)
{
try
{
String LocalFileName = Ftp.ListDirectory("/reports/").Where(f => f.Contains(NomeFile)).OrderBy(x => new FileInfo(x).CreationTime).Max();
Ftp.Download("/reports/" + LocalFileName, "c:\\temp\\" + LocalFileName, true);
return LocalFileName;
}
catch(Exception ex)
{
return string.Empty;
}
}
}