我打开一个PrintDialog盒子,然后用这个设置打印信息;
DialogResult result = PrintDialog.ShowDialog();现在,当我点击'Apply‘按钮时,我想保存printDialog的信息。当我再次打开printDialog框时,以前的设置不应该改变。
发布于 2015-10-05 17:26:44
将该信息STore到某个文件中,下次打开应用程序时,检查该文件是否包含所需的信息,如果包含该信息,则在应用程序中使用该信息,否则从用户处获取该信息
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();
}
}https://stackoverflow.com/questions/32945127
复制相似问题