forked from wenhelinlu/RTFEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHtmlResult.cs
34 lines (31 loc) · 1.2 KB
/
HtmlResult.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System.Collections.Generic;
using System.IO;
namespace Rtf2HtmlMod
{
public class HtmlResult
{
public string Html { get; set; }
public Dictionary<string, byte[]> Content { get; }
public HtmlResult()
{
Html = string.Empty;
Content = new Dictionary<string, byte[]>();
}
public void WriteToFile(string fileName)
{
File.WriteAllText(fileName, Html);
var fileInfo = new FileInfo(fileName);
foreach (var content in Content)
{
// GetFullPath converts forward slashes, cf.:
// http://stackoverflow.com/questions/3144492/how-do-i-get-nets-path-combine-to-convert-forward-slashes-to-backslashes
var contentFileName = Path.GetFullPath(Path.Combine(fileInfo.DirectoryName, content.Key));
var contentPath = Path.GetDirectoryName(contentFileName);
if (!Directory.Exists(contentPath))
// ReSharper disable once AssignNullToNotNullAttribute
Directory.CreateDirectory(contentPath);
File.WriteAllBytes(contentFileName, content.Value);
}
}
}
}