Cem Aytekin
Cem Aytekin

Reputation: 93

Reading any type of file in C#

My program needs to read any type of file from a given directory path and it has to write that information into a byte array.

 string combine = Path.Combine(precombine, filename);
 string content = System.IO.File.ReadAllText(combine);

This way I can read a text file however I have to read all kind of files such as music or image and write them into a byte array.

Upvotes: 0

Views: 1673

Answers (1)

Oscar Siauw
Oscar Siauw

Reputation: 483

Use the File.ReadAllBytes method

byte[] fileContent = System.IO.File.ReadAllBytes(combine);

Upvotes: 1

Related Questions