Jump to content
Xtreme .Net Talk

Recommended Posts

  • Moderators
Posted
   Public Function SaveToFile(ByVal saveThis As String) As Boolean
       Try
           Dim sb As New FileStream(Application.StartupPath & "\test.txt", FileMode.OpenOrCreate)
           Dim sw As New StreamWriter(sb)

           sw.Write(saveThis)
           sw.Close()

           Return True
       Catch
           Return False
       End Try
   End Function

   Private Function OpenFile() As Boolean
       Dim sr As StreamReader
       sr = File.OpenText(Application.StartupPath & "\test.txt")

       Dim strItems As String
       'loop through the text file
       While sr.Peek <> -1
           strItems = sr.ReadLine()

           'using [b]strItems[/b] add eachline to something here 
       End While
       sr.Close()

       Return True 'file was there...with no errors
   End Function

Visit...Bassic Software
  • Leaders
Posted
Thanks Robby, I was hoping to see an example that used BeginRead/Write and EndRead/Write to reduce the need to load the entire file into memory in order to read it. For example, if you had a B+Tree and knew the size of every node and want to only load one specific subtree into memory and not the entire file.
--tim

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...