Visual Basic
|
|
 |

|
I'm messing around (experimenting) with some Flash Action Script Text file.
I want to read the file, and display it in html for a preview, sort of like a thumbnail view.
I tried File.ReadAllLines, but it stripped out all the tabs and linefeeds.
So I tried reading the stream, converting from bytes to chars. So now I have a string array of text lines in char form,
[Question]
I can detect &H9 for the tab in byte, but I'm not sure how to detect the char version of &H9 which shows up as ""c
[EDIT][Objective]
I want to do some formatting, in which I replace the tab with or something, and perhaps do some color coding for comments in green, and so forth for use on a web page.
Perhaps I should leave the text the way it is, and just use a richText object, which might accept the strings in the current form.
Dim asStream As FileStream = New FileStream(physicalPath, FileMode.Open, FileAccess.Read)
Dim asLen As Long = asStream.Length
Dim fileData As Byte() = New Byte(asLen) {}
asStream.Read(fileData, 0, asLen)
asStream.Close()
Dim byteLine() As Byte = New Byte() {}
Dim strArray() As String = New String() {}
For bdx As Integer = 0 To fileData.Length - 1
Dim byteVal As Byte = fileData(bdx)
If Not (byteVal = &HD) Then
Array.Resize(byteLine, byteLine.Length + 1)
byteLine(byteLine.Length - 1) = byteVal
Else
Array.Resize(byteLine, byteLine.Length + 1)
byteLine(byteLine.Length - 1) = byteVal
Dim charLine() As Char = New Char() {}
Array.Resize(charLine, byteLine.Length + 1)
For cdx As Integer = 0 To byteLine.Length - 1
charLine(cdx) = AsciiByteToChar(byteLine(cdx))
Next
Dim value As String = New String(charLine)
Array.Resize(strArray, strArray.Length + 1)
strArray(strArray.Length - 1) = value
Array.Resize(byteLine, 0)
bdx += 1
End If
Next
|
|
|
|
 |
|
|
General
News
Suggestion
Question
Bug
Answer
Joke
Rant
Admin