我打开一个PrintDialog对话框,然后使用this设置打印信息;
DialogResult result = PrintDialog.ShowDialog();
现在,当我点击"应用"按钮时,我想保存printDialog的信息。当我再次打开printDialog框时,之前设置的设置不应该改变。
将该信息存储在某个文件中,下次打开应用程序时,检查该文件是否包含所需信息,如果包含该信息,则在应用程序中使用该信息,否则从用户处获取
string filename = "file.txt";
PrintDialog pd = new PrintDialog();
if (File.ReadAllText(filename).Count() > 0)
{
//printer setting should be applied using this file
//read the filename line by line and apply the setting
pd.PrinterSettings.PrinterName=""; //line 1 of file..
.
.
.
.
}
else
{
DialogResult result = pd.ShowDialog();
if (result == DialogResult.OK)
{
StreamWriter sw = new StreamWriter(filename);
sw.WriteLine(pd.PrinterSettings.PrinterName);
.
.
.
.
sw.Close();
}
}