|
using System.IO;
using System.Reflection;
using System.Text;
namespace MediaAssistant.DAL
{
public class ResourceHelper
{
public static void CopyEmbededResource(string resource, string destinationFilename)
{
var resourceStream = Assembly.GetCallingAssembly().GetManifestResourceStream(resource);
if (resourceStream == null) return;
var buffer = new byte[resourceStream.Length];
resourceStream.Read(buffer, 0, buffer.Length);
resourceStream.Close();
var fileStream = File.Create(destinationFilename);
fileStream.Write(buffer, 0, buffer.Length);
fileStream.Close();
}
public static string ReadText(string resource)
{
var resourceStream = Assembly.GetCallingAssembly().GetManifestResourceStream(resource);
var buffer = new byte[resourceStream.Length];
resourceStream.Read(buffer, 0, buffer.Length);
resourceStream.Close();
var encoding=new UTF8Encoding();
return encoding.GetString(buffer);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.