I have a series of PDF files called “LASTNAME, FIRSTNAME - REPORT.PDF”
I have “LASTNAME, FIRSTNAME” loaded in a data table, and assigned to Dictionary<String,String> variable.
i’m trying to look up the file name against the dictionary using this: but the “- REPORT” in the name is obviously causing problems.
how can i remove the extra words from the search or is there a better way? I’m trying to set a PDF password using a corresponding code in the data table.
However, there might be 2 or more matches. For example, “John Smith” and “John Smith Jr”
It might be better to check count of matches as the following.
Thanks Yoichi,
There will certainly be many matches as there will be “Lastname, Firstname Middlename - report”
And identical last and first but different middle name. is there a way to remove the last N characters from the string? the “- Report” is consistent for ever file name.
You can directly use a search pattern in your DIrectory.GetFiles that will give you required pdf Directory.GetFiles(“”,“" + FirstName + ".pdf”) . Include as many as you need.