Hente indhold i tekstfil
Hej EksperterJeg har en funktion til min Web service det skal hente indholdet af txt-fil.
Indholdet i filen er: Tekst tekst tekst tekst tekst tekst.
Men Funktionen laver indholdet om til: VGVrc3QgdGVrc3QgdGVrc3QgdGVrc3QgdGVrc3QgdGVrc3Qu
Hvordan kan det være?
Her er funktionen:
Private Shared Function ReadFile(ByVal FilePath As String) As Byte()
Dim fs As FileStream
Try
fs = File.Open(FilePath, FileMode.Open, FileAccess.Read)
Dim lngLen As Long = fs.Length
Dim abytBuffer(CInt(lngLen - 1)) As Byte
fs.Read(abytBuffer, 0, CInt(lngLen))
Return abytBuffer
Catch exp As Exception
Return Nothing
Finally
If Not fs Is Nothing Then
fs.Close()
End If
End Try
End Function
-KAHS
