D K

D K

  • NA
  • 2
  • 419

C# - Pdfdocument - FileNotFound

Jan 18 2019 4:19 PM
  1.  public static void CreatePDFx(string path)  
  2. {  
  3.   PdfDocument outputDocumentx = new PdfDocument();  
  4. }  
  5.   
  6. foreach (string pat_folder in pat_folders)  
  7.  {  
  8.          // Initially create PDFs  
  9.         Console.WriteLine("Watching this folder {0}", pat_folder);  
  10.               
  11.         try  
  12.         {  
  13.                CreatePDFx(pat_folder);  
  14.         }  
  15.         catch (FileNotFoundException ex)  
  16.         {  
  17.        // Write error.  
  18.         System.IO.File.WriteAllLines(@"C:\filenotfound.txt""Error");  
  19.          Console.WriteLine(ex);  
  20.         }  
  21. }  
I have the problem that my function always thorugh an "FileNotFoundException". I have found out that it could be a problem with line 3 in the snippet. pat_folder is only a string with a path. Its not the complete code. I am using the PDFsharp class. 

Could anyone help me and tell me, why it always throw an exception? Any ideas? Thanks in advance! 

Answers (3)