openxml을 사용하여 Excel 및 PowerPoint 문서를 만듭니다. emtpy 파일을 생성하고 싶지 않기 때문에, 자신의 Save
메소드를 사용하여 완료되었을 때만 문서를 작성하고 싶습니다. 그것은 weel를 작동합니다.클래스 속성 MemoryStream 및 IDisposable 사용
개발 중에 충돌이 발생하면 대개 DLL 파일을 잠시 차단합니다. IDisposable이 제대로 호출되지 않았다고 생각했습니다. 내 클래스 속성에서 사용을 정의하는 방법이 있습니까 _MemStream
?
public partial class Presentation
{
public Pa.PresentationDocument PresentationDoc { get; set; } //PresentationPart parts
private MemoryStream _MemStream { get; set; }
public void Init(string FileName = "NoName")
{
//Init stream
this._MemStream = new MemoryStream();
this.PresentationDoc = Pa.PresentationDocument.Create(
this._MemStream, PresentationDocumentType.Presentation);
// Create the presentation
}
public string Save(string path)
{
this.PresentationDoc.Close();
using (FileStream fileStream = new FileStream(FileTemp,
System.IO.FileMode.CreateNew))
{
this._MemStream.WriteTo(fileStream);
}
this._MemStream.Flush();
}
}
'IDisposable'는 [프로세스를 종료 할 경우 도움이 될하지 않습니다 (http://stackoverflow.com/a/34464312/993547). –
이것은 내가 찾고있는 것이다 : 클래스 속성 대신 "using"을 사용하는 방법이 있는가? 개인 MemoryStream처럼 _MemStream {get; using (set); } – Yoyo