I have been using these for a while... May fit the bill:
Public Function FILE_ReadIntoString(ByVal FileNameAndPath As String) As
String
Try
Dim myfile As System.IO.File
Dim Line As String
'Dim myStream As System.IO.FileStream
If myfile.Exists(FileNameAndPath) = True Then
' Create a file to write to.
Dim myStream As System.IO.StreamReader = myfile.OpenText(FileNameAndPath)
FILE_ReadIntoString = myStream.ReadToEnd
myStream.Close()
Else
App_Print("ERROR: FILE_ReadIntoString: Could not find file: " &
FileNameAndPath)
End If
'The problem is not so much loading files into strings as what happens next
'in the code. Adding this line should help .Net make room.
GC.Collect()
Catch ex As Exception
FILE_ReadIntoString = ""
App_Print("Error - FILE_ReadIntoString: " & ex.ToString)
End Try
End Function
Public Function FILE_WriteFile(ByVal OutputString As String, ByVal
OutputFileName As String) As Boolean
Try
Dim myFile As System.IO.File
Dim myFileStream As System.IO.FileStream
Dim myByteArray As Byte()
Dim MyEncoder As New System.Text.ASCIIEncoding
myFileStream = myFile.Create(OutputFileName)
myByteArray = MyEncoder.GetBytes(OutputString)
myFileStream.Write(myByteArray, 0, myByteArray.Length)
myFileStream.Close()
FILE_WriteFile = True
Catch ex As Exception
FILE_WriteFile = False
App_Print("Error - FILE_WriteFile: " & ex.ToString)
End Try
End Function
"Greg Chu" <gr******@wendys.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
Hi, any way to send a string directly to a file on the hard drive?
Thanks!
Greg