简体   繁体   中英

How to convert video file name to byte array

Hi I am trying to convert my video file name that i have extracted from a folder to a byte array. My file name goes "video.mp4"

I have tried using this set of codes

byte[] bytes = System.IO.File.ReadAllBytes(filename);

but it does not work. Anyone?

Another (maybe easier way) to convert a string to a byte array goes like this:

string filename = "video.mp4";
byte[] byteArray = Encoding.ASCII.GetBytes(filename);

To convert the byte array back to a string you can use:

string filename = Encoding.ASCII.GetString(byteArray);

For this to work you'll need to import the System.Text namespace.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM