本文整理汇总了C#中System.IO.Packaging.Package.Flush方法的典型用法代码示例。如果您正苦于以下问题:C# Package.Flush方法的具体用法?C# Package.Flush怎么用?C# Package.Flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.Packaging.Package
的用法示例。
在下文中一共展示了Package.Flush方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveAs
/// <summary>
/// Save the package to a file.
/// </summary>
/// <param name="path">The file path of the package. Any existing file will be overwritten.</param>
/// <param name="rsaParamsXml">RSA key serialized to XML. If null, save an unencrypted package.</param>
public void SaveAs(string path, string rsaParamsXml)
{
MemoryStream ms;
bool needContentHack = IsNew;
//
CondCreateStream();
SaveManifest();
_package.Flush();
if (needContentHack) // Flush() doesn't flush the [Content_Types].xml file! Arghh!
{
_package.Close();
_stream.Position = 0;
_package = Package.Open(_stream, FileMode.Open, FileAccess.ReadWrite);
_package.Flush();
}
_stream.Flush();
ms = Encrypt(_stream, rsaParamsXml);
using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.ReadWrite))
{
ms.Position = 0;
CopyStream(fs, ms);
}
_path = path;
}