Created
April 20, 2018 10:23
-
-
Save tomaustin700/1eb5a98ec4c866393e0a31ea042f1b39 to your computer and use it in GitHub Desktop.
Converts SQL varbinary image into C# Byte[]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string stringFromSQL = "0x6100730064006600"; | |
List<byte> byteList = new List<byte>(); | |
string hexPart = stringFromSQL.Substring(2); | |
for (int i = 0; i < hexPart.Length / 2; i++) | |
{ | |
string hexNumber = hexPart.Substring(i * 2, 2); | |
byteList.Add((byte)Convert.ToInt32(hexNumber, 16)); | |
} | |
byte [] original = byteList.ToArray(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment