Is it possible to use TextFieldParser on Byte? I am uploading a file via a Web Service using Byte and I am having some trouble figuring out if I can access this CSV directly or if I need to first write it to disk. Writing it to disk would be easy, but I am not convinced I need to do so.
TextFieldParser accepts System.IO.Stream, System.String (path to file), or System.IO.TextReader but I cannot figure out if I can get the Byte into one of those easily.
This is what I am looking at and what I would like to do (this code doesn’t work)
Public Function Import(ValidationKey As String, FileBytes() As Byte) As String
Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(FileBytes)
MyReader.TextFieldType = FileIO.FieldType.Delimited
MyReader.SetDelimiters(",")
'other code here
End Using
'other code here
End Function
You can read the
bytearray into aMemoryStream–TextFieldParserwill accept it.