Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

which encoding is used for File.WriteAllBytes()in default?
Is it possible to specify any specified encoding in File.WriteAllBytes()?

eg:-File.WriteAllBytes(filePath, data)
where 'filePath' is specified location to create the file and 'data' is Byte[]
Posted
Comments
David Ewen 9-Nov-10 23:31pm    
There is no encoding for WriteAllBytes. Encoding relates to how strings are turned into bytes if you already have a byte array then the encoding has already been applied elsewhere.

1 solution

If you look at the definition for File.WriteAllBytes http://msdn.microsoft.com/en-us/library/system.io.file.writeallbytes.aspx[^] you will see that it has only the single signature: it takes an array of bytes as a parameter and outputs it to a new file.

Since an array of bytes is defined as a sequence of 8 bit unsigned binary data http://msdn.microsoft.com/en-us/library/e2ayt412(VS.71)[^] it has no encoding, nor does it need one.

Any encoding change is performed when you convert a string to an array of bytes.
 
Share this answer
 
Comments
Nithin kd 11-Nov-10 4:41am    
thank you..its clear now.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900