Skip to content

Commit

Permalink
Better handling of document saving
Browse files Browse the repository at this point in the history
  • Loading branch information
clearly committed May 10, 2012
1 parent cbfce76 commit 357e715
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion RazorPad.Contracts/IRazorDocumentSaver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ public static void Save(this IRazorDocumentSaver saver, RazorDocument document,

document.DocumentKind = RazorDocument.GetDocumentKind(filename);

using (var stream = File.Open(destination, FileMode.Truncate, FileAccess.Write))
FileInfo fiTarget = new FileInfo( destination );

if( fiTarget.Exists )
{
fiTarget.Delete();
}

using (var stream = fiTarget.OpenWrite() )
{
saver.Save(document, stream);

Expand Down

0 comments on commit 357e715

Please sign in to comment.