Convert a File Into ByteArray

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • malligarjunank
    New Member
    • Apr 2007
    • 10

    Convert a File Into ByteArray

    Hi all,

    How to convert a file into byte of array and how to convert the Byte array into file.

    Please Give me an sample for above
  • blackjack2150
    New Member
    • Feb 2007
    • 79

    #2
    Originally posted by malligarjunank
    How to convert a file into byte of array and how to convert the Byte array into file[?]
    This is how you read the file into a byte array:

    FileStream fs = new FileStream(file One, FileMode.Open);
    byte[] rawData = new byte[fs.Length];
    fs.Read(rawData , 0, (int)fs.Length) ;


    For the opposite operation, use the "Write" method instead and also change the "FileMode" in the consttuctor to "FileMode.Creat e".

    Comment

    Working...