private static byte[] GetContents(string name)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException("name", "name must contain a value.");
}
byte[] buffer;
using (Stream stream = typeof(StaticFileHandler).Assembly.GetManifestResourceStream(name))
{
if (stream == null)
{
throw new FileNotFoundException("The specified file is not a valid embedded static file resource.", name);
}
buffer = new byte[stream.Length];
int count = 0;
while (count < buffer.Length)
{
count = stream.Read(buffer, count, buffer.Length);
}
}
return buffer;
}