Not able to WriteLine differences between folder of files and reference txt list...

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi All,
I have a second project Im working on that checks the count and names of pdf files in a directory against a .txt file list of expected file names.
So the result I need is to see is: that the count of files in the folder is the same as the count of files in the reference list (ie 100 files in Folder A and 100 file names in List.txt)
and if there is a discrepancy, print out the file names of the missing pdf names.
Here is my code: //Variables for path, expected total files and file type
string proList = @"Y:aBULKProjectszARCHIVE__LIVE_ARCHIVEaaLIVE_2013aaLive_2013_02ChartBook_PDFs_201301cb.uk.201301.webexpectedProUk.txt";
string proFolder = @"Y:aBULKProjectszARCHIVE__LIVE_ARCHIVEaaLIVE_2013aaLive_2013_02ChartBook_PDFs_201301cb.uk.201301.web";
try
{
//Read the text file to memory
StreamReader sr = new StreamReader(proList);
String line = sr.ReadToEnd();
//read the folder files to memory
var sourceFiles = Directory.GetFiles(proFolder, fileTypes).Select(o => Path.GetFileName(o));

//Run through each file name in folder
foreach (string str in sourceFiles)
{
//Write to console the names of the files in the folder
Console.WriteLine(str);
}

//Var to total number of files in folder
string[] theFilesSourceLength = Directory.GetFiles(proFolder, fileTypes);
int sourceTotal = theFilesSourceLength.Length;

//Write number of files found in the folder
Console.WriteLine("nFiles from folder: {0}", sourceTotal.ToString());
//Write number of files found in the list
CountLinesInFile clif = new CountLinesInFile();
clif.CountingLines(proList);
//Var to hold difference file names
var diffFiles = sourceFiles.Except(line);
Console.WriteLine(diffFiles);
}
The line var diffFiles = sourceFiles.Except(line); does not fly saying it has some invlaid arguements.
Does this code look right to you guys?
Lee Warren

View the full article
 
Back
Top