fb:porticula NoPaste
Text File to string very fast
Uploader: | marpon |
Datum/Zeit: | 23.01.2013 10:05:45 |
Hinweis: Dieser Quelltext ist Bestandteil des Projekts CSED_FB multi-language Windows IDE for FreeBasic, zu dem es auf FreeBASIC-Portal.de eine Projektseite gibt.
'Text File to string very fast
'
'usage: mes = File_String(Name_File As String) As String
'
'
Function File_String(Nom_File As String) As String
Dim fileData As UByte Ptr
Dim As Integer fileSize, result
Dim As Integer myHandle
Dim As String cont
myHandle = Freefile()
result = Open (Nom_File For Binary As #myHandle )
If result <> 0 Then
Function= ""
Exit Function
EndIf
fileSize = LOF(myHandle)
If fileSize=0 Then
Function =""
Close #myHandle
Exit Function
EndIf
fileData = Allocate(fileSize)
Get #myHandle, 0, *fileData, fileSize
Close #myHandle
cont= *fileData
Function = Left$(cont,fileSize)
Sleep(1)
Deallocate(fileData)
End Function