本文整理汇总了C#中IDocument.SaveTo方法的典型用法代码示例。如果您正苦于以下问题:C# IDocument.SaveTo方法的具体用法?C# IDocument.SaveTo怎么用?C# IDocument.SaveTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDocument
的用法示例。
在下文中一共展示了IDocument.SaveTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Convert
/// <summary>
/// Converts the specified args.
/// </summary>
/// <param name="args">The args.</param>
public void Convert(params object[] args)
{
try
{
_start = DateTime.Now;
_iDocument = this.GetIDocument(args[0] as String);
_iDocument.Load(args[0].ToString());
_iDocument.SaveTo(args[1].ToString());
_elapsedTime = DateTime.Now - _start;
Thread.Sleep(1000);
OnFinished();
}
catch(Exception ex)
{
if(!ex.Message.ToLower().StartsWith("thread was"))
{
this.Controler_OnReady();
OnCException(ex);
}
}
}
示例2: CreateStream
/// <summary>
/// Saves the provided document to a stream and returns it.
/// </summary>
/// <param name="doc"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"><paramref name="doc"/> was null.</exception>
protected Stream CreateStream(IDocument doc)
{
if (doc == null)
{
throw new ArgumentNullException("doc");
}
string filePath = Path.Combine(Path.GetTempPath(), string.Format("~odf_{0}.{1}", DateTime.UtcNow.ToFileTime(), this.FileExtension));
FileInfo tmp = new FileInfo(filePath);
try
{
using (tmp.Create()) { }
tmp.Attributes = FileAttributes.Temporary;
doc.SaveTo(tmp.FullName);
MemoryStream stream = new MemoryStream();
using (FileStream fs = tmp.OpenRead())
{
fs.CopyTo(stream);
}
return stream;
}
finally
{
tmp.Delete();
}
}