我正在使用WinForms。我有一個這種形式的按鈕。當點擊按鈕時,我希望程序每次點擊它時都打印一個特定的文件。在您的計算機C中打印特定文件#
我的問題是:我的代碼不打印我的電腦中的特定文件。它打印出一個空白的文件。
例如:按鈕點擊一直打印文檔「C:\ image.jpg」。
private void btn_Print_Click (object sender, EventArgs e)
{
printDialog1.AllowSomePages = true;
printDialog1.AllowSelection = true;
printDocument1.PrinterSettings.PrintToFile = true;
if (printDialog1.ShowDialog() == DialogResult.OK)
{
printDialog1.PrinterSettings.PrintFileName = @"C:\\image";
printDocument1.Print();
}
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
}
感謝那些@xPeke –
我不知道如何打印特定文件從我的電腦@xPeke –
是否可能與權限相關?您是否能夠使用Windows資源管理器在程序之外打印C:\ image?我沒有看到您提供的代碼有任何問題 – Krondorian