保存文件时,如何设置文件名称
保存文件时,怎么将文件名称设置上去?我的保存方法,传入一个名称,但在“另存为”的窗口没有显示出来,该怎么操作呢?public void FileSaveAsPDF(string title)
{
TXTextControl.StreamType streamType = TXTextControl.StreamType.AdobePDF;
TXTextControl.SaveSettings SaveSettings = new TXTextControl.SaveSettings();
SaveSettings.DocumentTitle = title;
_textControl.Save(streamType, SaveSettings);
}
回复 1# forachange 的帖子
可以使用这样的方法来保持:Microsoft.Win32.SaveFileDialog save = new Microsoft.Win32.SaveFileDialog();
save.FileName = "test.pdf";
save.Filter = "Adobe PDF(*.pdf)|*.pdf";
if (save.ShowDialog() == true)
{
textControl1.Save(save.FileName, TXTextControl.StreamType.AdobePDF);
} 谢谢dof. :iggle 还有,若是需要保存为多种格式,这时文件名称如何设置上去呢?
我的代码:
const TXTextControl.StreamType DefaultSaveTypes = TXTextControl.StreamType.AdobePDF |
TXTextControl.StreamType.AdobePDFA |
TXTextControl.StreamType.MSWord |
TXTextControl.StreamType.WordprocessingML |
TXTextControl.StreamType.RichTextFormat;
public void FileSaveAs(string title)
{
TXTextControl.StreamType streamType = DefaultSaveTypes;
TXTextControl.SaveSettings SaveSettings = new TXTextControl.SaveSettings();
SaveSettings.DocumentTitle = title;
_textControl.Save(streamType, SaveSettings);
}
也可以使用类似的方法吧:
Microsoft.Win32.SaveFileDialog save = new Microsoft.Win32.SaveFileDialog();
save.FileName = "test";
save.Filter = "Adobe PDF(*.pdf)|*.pdf|WordprocessingML(*.docx)|*.docx";
save.AddExtension = true;
if (save.ShowDialog() == true)
{
_textControl.Save(save.FileName,"需要动态指定类型");
} 谢谢dof。
原来也这么试过,但Filter写错了,所以报错。现在解决了。 OK!!!
页:
[1]