Q: On print- if chooses save PDF, if the file name exist crash the computer In print, if the user chooses to save a PDF, if there is already a file of the same name, it brings up a dialog box: "File exist. Do you want to replace it?". If I click "Yes" it will crash the computer because dialog box not close.
my code:
  PrintDialog printDialog1 = new PrintDialog();
    PrinterSettings settings = new PrinterSettings();
    static PrintDocument page = new PrintDocument();
public void printPage()
{
        printDialog1.Document = page;
        DialogResult result = printDialog1.ShowDialog();
        page.PrintPage += new PrintPageEventHandler(page_PrintPage);

        if (result == DialogResult.OK)
        {
          try
          {
             settings = printDialog1.PrinterSettings;
             printDialog1.Document.DocumentName = myNameDocument;
             page.Print();
             printDialog1.Dispose();
          }
          catch(Exception ex)
          {
              MessageBox.Show(ex.Message);
          }
        }
    }

private void page_PrintPage(object sender,PrintPageEventArgs e)
{
   Graphics graphic=e.Graphics;
   SolidBrush brush = new SolidBrush(Color.Black);
   e.PageSettings.PaperSize=new PaperSize("A4",850,1100);
   Font font=new Font("Ariel",12,FontStyle.Bold);
   graphic.DrawString("print O.K.", font, brush, 100, 100);
}


A: I edit the code- It is in method. Icall the method from another class. I add try/catch.
The problem is when I choose "Adobe PDF" in printer dialog, than I need to save with file name. The default name is document name and if I want print the same page second time the problem happened.
Now I solved the problem with add dateTime.Now.Tostring() to the document name, so the file's name change every time but the base problem don't solved yet.
