■ FlowDocument 클래스 : XAML 데이터 저장하기

----------------------------------------------------------------------------------------------------

using System.IO;

using System.Windows;

using System.Windows.Documents;

 

#region XAML 데이터 저장하기 - SaveXAMLData(flowDocument, filePath)

 

/// <summary>

/// XAML 데이터 저장하기

/// </summary>

/// <param name="flowDocument">FlowDocument 객체</param>

/// <param name="filePath">파일 경로</param>

public void SaveXAMLData(FlowDocument flowDocument, string filePath)

{

    TextRange textRange = new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd);

 

    Stream stream = null;

 

    try

    {

        stream = new FileStream(filePath, FileMode.Create);

 

        textRange.Save(stream, DataFormats.Xaml);

    }

    finally

    {

        if(stream != null)

        {

            stream.Close();

        }

    }

}

 

#endregion

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요