开发者

Silverlight Byte[] to its original file format

is there a way to convert byte[] to its original file format?

Byte[] tempByte = new Byte[content.Length];
tempByte = Convert.FromBase64String(c开发者_高级运维ontent);


If you have a Base64 encoded string, then yes Convert.FromBase64String will give you back a byte array identical to the one that was converted to a Base64 string.

However, your first line is unnecessary. You are allocating an array equal to the length of content which just gets overwritten by the return value from Convert.FromBase64String.

byte[] tempByte = Convert.FromBase64String(content);

File.WriteAllBytes(path, tempByte);


The byte array should already be having what you originally read from the file. Write the byte array to a file on the disk and you should be good to go!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜