Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

file to byte array

//Files less than 600MB
byte[] file = System.IO.File.ReadAllBytes(fileName);

//Files greater than 600MB
public byte[] FileToByteArray(string fileName)
{
    byte[] fileData = null;

    using (FileStream fs = File.OpenRead(fileName)) 
    { 
        using (BinaryReader binaryReader = new BinaryReader(fs))
        {
            fileData = binaryReader.ReadBytes((int)fs.Length); 
        }
    }
    return fileData;
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# return 2 values 
Csharp :: long number multiplication 
Csharp :: exceldatareader example c# 
Csharp :: else if c# 
Csharp :: disable button in android studio 
Csharp :: asp.net core miniprofiler 
Csharp :: c# datagridview select row right click 
Csharp :: c# enum 
Csharp :: use slider in unity 
Csharp :: unity camera follow with lerp 
Csharp :: C# network traffic 
Csharp :: text read C# 
Csharp :: c# csvhelper 
Csharp :: c# close form 
Csharp :: Edit file C# 
Csharp :: how to upload an image to an image source c# 
Csharp :: c# int 
Csharp :: c# allowedusernamecharacters 
Csharp :: c# string console readline array 
Csharp :: deserialize json to dynamic object c# 
Csharp :: get both item and index in c# 
Csharp :: autofac .net core 6 
Csharp :: asp .net core 3 mvc select with default value 
Csharp :: convert pdf to image c# 
Csharp :: list sum c# 
Csharp :: shut game unity 
Csharp :: c# list find index 
Csharp :: longest substring without repeating characters leetcode 
Csharp :: winforms input box 
Csharp :: div element position in screen 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =