forachange 发表于 2012-5-30 18:17:00

保存文件时,如何设置文件名称

保存文件时,怎么将文件名称设置上去?
我的保存方法,传入一个名称,但在“另存为”的窗口没有显示出来,该怎么操作呢?public void FileSaveAsPDF(string title)
      {
            TXTextControl.StreamType streamType = TXTextControl.StreamType.AdobePDF;
            TXTextControl.SaveSettings SaveSettings = new TXTextControl.SaveSettings();
            SaveSettings.DocumentTitle = title;               
            _textControl.Save(streamType, SaveSettings);
      }

ZenosZeng 发表于 2012-6-1 16:10:00

回复 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);
    }

forachange 发表于 2012-6-6 17:24:00

谢谢dof.

ZenosZeng 发表于 2012-6-8 13:49:00

:iggle

forachange 发表于 2012-6-18 10:13:00

还有,若是需要保存为多种格式,这时文件名称如何设置上去呢?
我的代码:

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);            
      }

ZenosZeng 发表于 2012-6-18 18:09:00

也可以使用类似的方法吧:
   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,"需要动态指定类型");
   }

forachange 发表于 2012-6-18 18:26:00

谢谢dof。
原来也这么试过,但Filter写错了,所以报错。现在解决了。

ZenosZeng 发表于 2012-6-19 14:10:00

OK!!!
页: [1]
查看完整版本: 保存文件时,如何设置文件名称