Results 1 to 40 of 61

Thread: [RESOLVED] How to write a generic contact List to a file that's inside a List(of contacs)

Threaded View

  1. #11

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,437

    Re: How to write a generic contact List to a file that's inside a List(of contacs)

    just found an Oops in the code. I kept getting one of my favorite errors for files. It's about not being able to do anything with the file because it was in use by another process. And as I'm sure you all know, the other process is us. I always managed to fix it, but never understood how or why.

    I guess code first:

    Code:
            Dim writeFile As String = "tmpfile.txt"
            'sw = AppendText(writeFile)
            For Each person As Contact In contacts
                Using sw
                    sw = AppendText(writeFile)
                    sw.WriteLine("Hello")
                End Using
            Next
    You'll see that I have commented out the first "AppendText" line. This was the offending code. With that code being there, I had to close the file before I could write to it. Didn't make "any" sense to me. So I commented out that line and everything worked perfectly (before I was getting that exception). So if anyone reads this who is as dumb as me, this would be a good lesson. It really taught me a good one

    thanks again everyone
    Last edited by jumper77; Apr 17th, 2016 at 08:17 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width