writing to a txt file, then opening and reading
hi, below is some code i'm using, everything works and "MsgBox base64Str" prompts the correct value, but instead of MsgBox, i'm trying to create a text file, write the values of base64Str to the file, then open it for reading, this is what i have so far (after the MsgBox base64Str)
thanks:
VB Code:
' Base64 ActiveX creation:
set obj = CreateObject("Base64.Base64")
' Load a GIF image file into memory.
binaryData = obj.LoadBinaryFile("Prem.gif")
' Convert the binary data to a base64 string
base64Str = obj.ToBase64(binaryData)
' Display the base-64 string.
MsgBox base64Str
Dim oFile as System.IO.File
Dim oWrite as System.IO.StreamWriter
oWrite = oFile.CreateText(“C:\basecoder64\test.txt”)
oWrite.WriteLine(base64Str)
ooWrite.Close()
Dim EntireFile as String
oRead = oFile.OpenText(“C:\basecoder64\test.txt”)
EntireFile = oRead.ReadToEnd()
OpenText
Re: writing to a txt file, then opening and reading
Erm, this is VB.NET. I've never really liked the way .NET requires FileStream readers/writers. That format doesn't belong in VB IMO :)
Posting this in the .NET forum will turn up more help..
chem