Hello again Ekona, This would be quite simple, well depending on how you want them to be notified.
----- inside method
if (pdf_specFiles.Length > 0) {
bool itemFound = false;
foreach (object item in listBox1.Items)
{
foreach (string file in pdf_specFiles)
{
string fileName = Path.GetFileName(file);
if (fileName == item.ToString())
{
printList.Add(Path.GetFullPath(file));
itemFound = true;
}
}
if (!itemFound) {
OutputErrorMessage(item.ToString());
}
}
}
---- outside method
void OutputErrorMessage(string message) {
MessageBox.Show(message);
}
Keep in mind that would output an error message for each missing file.
This may not be so good, perhaps send one message for all missing files at the end.
You can use a string and keep += to it, though this is not an efficient way if there are many missing files. The alternative is using a StringBuilder.
----- Inside the method
if (pdf_specFiles.Length > 0) {
StringBuilder builder = new StringBuilder();
bool itemFound = false;
foreach (object item in listBox1.Items)
{
foreach (string file in pdf_specFiles)
{
string fileName = Path.GetFileName(file);
if (fileName == item.ToString())
{
printList.Add(Path.GetFullPath(file));
itemFound = true;
}
}
if (!itemFound) {
if (builder.Length == 0) {
builder.AppendLine("Missing Files");
}
builder.AppendLine(item.ToString());
}
}
foreach (string file in printList)
{
PrintDocument(file);
System.Threading.Thread.Sleep(10000);
Application.DoEvents();
}
if (builder.Length > 0) {
OutputErrorMessage(builder.ToString());
}
}
------- Outside the method
public void OutputErrorMessage(string messages) {
MessageBox.Show(messages, "You are missing files");
}