Get Bytes from files in .net
public static byte[] GetBytesFromFile(this string PhysicalFilePath)
{
FileStream stream = null;
byte[] buffer;
try
{
stream = File.OpenRead(PhysicalFilePath);
buffer = new byte[stream.Length];
stream.Read(buffer, 0, Convert.ToInt32(stream.Length));
}
catch
{
buffer = new byte[0];
}
finally
{
if (stream != null)
{
stream.Close();
stream.Dispose();
}
}
return buffer;
}
{
FileStream stream = null;
byte[] buffer;
try
{
stream = File.OpenRead(PhysicalFilePath);
buffer = new byte[stream.Length];
stream.Read(buffer, 0, Convert.ToInt32(stream.Length));
}
catch
{
buffer = new byte[0];
}
finally
{
if (stream != null)
{
stream.Close();
stream.Dispose();
}
}
return buffer;
}
Get Bytes from files in .net
Reviewed by Vikas Kumar Singh
on
December 03, 2017
Rating:
No comments: