1
|
|
using System.IO;
|
2
|
|
using System.Reflection;
|
3
|
|
using log4net;
|
4
|
|
|
5
|
|
namespace ShowX.Helper
|
6
|
|
{
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
public class ResourceHelper
|
11
|
|
{
|
12
|
|
private static readonly ILog log = LogManager.GetLogger(
|
13
|
|
typeof(ResourceHelper));
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
|
18
|
|
|
19
|
|
|
20
|
|
|
21
|
0
|
public static void WriteResourceToFile(Assembly assembly, string resource,
|
22
|
|
string filename)
|
23
|
|
{
|
24
|
|
log.Info(string.Format("Writing resource '{0}' to file '{1}'. Reading from"
|
25
|
|
+ " assembly {2}",resource,filename,assembly.GetName()));
|
26
|
|
|
27
|
|
Stream resStream = assembly.GetManifestResourceStream(
|
28
|
|
resource);
|
29
|
|
|
30
|
|
BinaryReader reader = new BinaryReader(resStream);
|
31
|
|
FileStream fs = new FileStream(filename,FileMode.Create);
|
32
|
|
|
33
|
|
for(int i=0; i < resStream.Length; i++)
|
34
|
|
fs.WriteByte(reader.ReadByte());
|
35
|
|
|
36
|
|
fs.Close();
|
37
|
|
log.Info("Done");
|
38
|
|
}
|
39
|
|
}
|
40
|
|
}
|
41
|
|
|