以下のコードを試してください。これは、別のSO スレッドのコードに基づいています。
private async void Button_Click_1(object sender, RoutedEventArgs e)
{
//dataReader.ReadBytes(bytes);
String machineId = BitConverter.ToString(bytes);
Guid guid;
bool isDataAVailale = GuidTryParse(machineId, out guid);
myText.Text = guid.ToString();
}
public static bool GuidTryParse(string s, out Guid result)
{
if (!String.IsNullOrEmpty(s) && guidRegEx.IsMatch(s))
{
result = new Guid(s);
return true;
}
result = default(Guid);
return false;
}
static Regex guidRegEx = new Regex("^[A-Fa-f0-9]{32}$|" +
"^({|\\()?[A-Fa-f0-9]{8}-([A-Fa-f0-9]{4}-){3}[A-Fa-f0-9]{12}(}|\\))?$|" +
"^({)?[0xA-Fa-f0-9]{3,10}(, {0,1}[0xA-Fa-f0-9]{3,6}){2}, {0,1}({)([0xA-Fa-f0-9]{3,4}, {0,1}){7}[0xA-Fa-f0-9]{3,4}(}})$", RegexOptions.Singleline);