Convert byte[] or object to GUID
byte[] binaryData = objData as byte[];
string strHex = BitConverter.ToString(binaryData);
Guid id = new Guid(strHex.Replace("-", ""))
The long form would be (enter link description here):
public static string ConvertGuidToOctectString(string objectGuid)
{
System.Guid guid = new Guid(objectGuid);
byte[] byteGuid = guid.ToByteArray();
string queryGuid = "";
foreach (byte b in byteGuid)
{
queryGuid += @"\" + b.ToString("x2");
}
return queryGuid;
}
How about using the Guid
constructor which takes a byte array?
Guid guid = new Guid(binaryData);
(You can then use Guid.ToString()
to get it in text form if you need to.)