I have the following method, which is meant to add file names to a List<string>
so that the desired order of the files is stored in the Program
class:
private static void ConvertPdfs()
{
// Get the word files FileInfo
FileInfo[] wordFileInfo = DataGrabber.GetHrWordFileInfo(sourceFolder, spSite, policyListName, sortBy);
foreach (FileInfo file in wordFileInfo)
{
// Create the ordered list - this adds each document to the list in the correct oder (sort in CAML query)
orderedListOfFileNames.Add(file.Name);
}
Converter convert = new Converter();
convert.ToPdf(wordFileInfo, targetPdf);
}
Where ordereListOfFileNames
is a field in that same class:
private static List<string> orderedListOfFileNames; // Stil static ...
When the method loops around wordFileInfo, I am seeing this exception:
An unhandled exception of type 'System.NullReferenceException' Occurred in PdfConverter.exe
Additional information: Object reference not set to an instance of an object.
However, I can see that wordFileInfo
contains 22 items, all of which have a name.
Is the issue here the fact that orderedListOfFileNames
has not been initialised properly?