47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
|
using System;
|
|||
|
using System.Dynamic;
|
|||
|
using System.Reflection;
|
|||
|
using System.IO;
|
|||
|
|
|||
|
namespace SpritePacker
|
|||
|
{
|
|||
|
public class Utilities
|
|||
|
{
|
|||
|
public static string[] GetEmbeddedResourceList()
|
|||
|
{
|
|||
|
return System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames();
|
|||
|
}
|
|||
|
|
|||
|
public static void PrintEnbeddedResourceList()
|
|||
|
{
|
|||
|
string[] resFiles = GetEmbeddedResourceList();
|
|||
|
foreach (string str in resFiles)
|
|||
|
Console.WriteLine("[{0}]", str);
|
|||
|
}
|
|||
|
|
|||
|
public static string GetEmbeddedResourceContent(string resourceName)
|
|||
|
{
|
|||
|
Assembly asm = Assembly.GetExecutingAssembly();
|
|||
|
Stream stream = asm.GetManifestResourceStream(resourceName);
|
|||
|
StreamReader source = new StreamReader(stream);
|
|||
|
string fileContent = source.ReadToEnd();
|
|||
|
source.Dispose();
|
|||
|
stream.Dispose();
|
|||
|
return fileContent;
|
|||
|
}
|
|||
|
|
|||
|
public static DateTime GetProgramBuildDate()
|
|||
|
{
|
|||
|
Version asmVersion = GetProgramVersion();
|
|||
|
return new DateTime(2000, 1, 1).Add(new TimeSpan(
|
|||
|
TimeSpan.TicksPerDay * asmVersion.Build +
|
|||
|
TimeSpan.TicksPerSecond * asmVersion.Revision * 2
|
|||
|
));
|
|||
|
}
|
|||
|
|
|||
|
public static Version GetProgramVersion()
|
|||
|
{
|
|||
|
return Assembly.GetEntryAssembly().GetName().Version;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|