I have an InfoPath XML file with a File Attach control. The file gets saved to the XML in base64. I can use Convert.FromBase64String to convert the data back into the original file, but the problem is, I have to know what kind of file it was. I am doing this: The problem is, what if the file attached wasn't a word doc, what if it was a Excel file? Is there a way to know what kind of file it is so I can save it with the correct extension? Can I possibly get the entire original file name?
VB Code:
  1. Dim binaryData() As Byte = Convert.FromBase64String(b64str)
  2. Dim fs As New FileStream("myFile.doc",   FileMode.CreateNew)
  3. fs.Write(binaryData, 0, binaryData.Length)
  4. fs.Close()