I have a list that contains string values. I need to trim the leading and ending values. Here is the code:
using EnterpriseDT.Net.Ftp;
public List<FTPFile> FileList = new List<FTPFile>();
FTP = new FTPConnection() { ServerAddress = _host, UserName = _user, Password = _password };
FTP.Connect();
FTP.TransferType = FTPTransferType.BINARY;
FTP.ChangeWorkingDirectory(_as400_directory);
FTP.LocalDirectory = _local_directory;
FileList.AddRange(FTP.GetFileInfos());
FTP.Close();
The FileList list contains following example values:
test 123 11/01/12 *STMF File1.csv somegarbagevalues
test 123 11/01/12 *STMF File2.csv somegarbagevalues
test 123 11/01/12 *STMF File3.csv somegarbagevalues
What I need to do is capture online the file name (ex. File1.csv, File2.csv …) Is there a way to trim the unwanted values without looping through the list or trim when I do the FileList.AddRange statement?
LINQ makes this easy:
where
Trim()would be a method (possibly an extension method) onFTPFilewhich returned anFTPFilewith trimmed filename.