I\'m loading an XML document in my C# application with the following:
XDocument xd1 = new XDocument();
xd1 = XDocument.Load(myfile);
but be
I would not XDocument.Load(), as per the accepted answer; why would you read the entire file into memory, it could be a huge file?
I'd probably read the first few bytes into a byteArray (it could even be any binary file), convert the byteArray to string
e.g. System.Text.Encoding.ASCII.GetString(byteArray)
,check if the converted string contains the Xml elements you are expecting, only then continue.