[Help] Byte array to string, Then in XML (LINQ)
I keep getting an error from this... some UNICODE ERROR!!!!!!!
[highlight="vb.net"]
Public Overrides Function ToString() As String
Dim file = My.Computer.FileSystem.ReadAllBytes("example.exe")
Dim fileR = System.Text.Encoding.ASCII.GetString(File)
Dim XML = <root>
<File><%= fileR %></File>
</root>
Return XML.ToString()
End Function
[/highlight]
By the way, you forgot to enclose your string with string deliminators.
no but I also want it smaller.. I currently using the code i showed above and it works but I want to be able to convert to string and Back with no mistakes
PS the XML way is Much easier compared to what you have.
topblast, i honestly think you need to go back and read up on what XML is. Jason posted XML (not a non-"XML way"), and the problems with your code have been pointed out time and time again.
Your way was easier? You manually wrote out an XElement, converted it instantly to string (not Value, just ToString, which returns exactly what my method did, without any conversions.) There is really NO NEED for it to be that complicated lol. As for the bytes, you're implicitly converting them, chances are you should explicitly convert the array to a compatible data-type.