GIDForums  

Go Back   GIDForums > Computer Programming Forums > .NET Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 14-Dec-2006, 07:35
dadio22 dadio22 is offline
Junior Member
 
Join Date: Sep 2006
Location: Breda, The Netherlands
Posts: 49
dadio22 is on a distinguished road
Arrow

Overwriting a textfile


I'm trying to overwrite a textfile using filestream and the a binarywriter for some reason it won't write what I want it to.

VB / Visual Basic Code:
    Public Sub saveafile(ByVal savefilenaam)

        newtest.eerste = TextBox1.Text
        newtest.tweede = TextBox2.Text
        newtest.derde = TextBox3.Text
        newtest.vierde = TextBox4.Text

        If File.Exists(savefilenaam) = True Then
            Dim fs As New FileStream(savefilenaam, FileMode.Open, FileAccess.Write)
        Else
            Dim fs As New FileStream(savefilenaam, FileMode.CreateNew)

            Dim w As New BinaryWriter(fs)

            w.Write(newtest.eerste)
            w.Write(newtest.tweede)
            w.Write(newtest.derde)
            w.Write(newtest.vierde)
            w.Close()
            fs.Close()
        End If

can someone help me it's getting very frustrating as you can imagine because it will write a new textfile sigh.

with greetz dadio22
__________________
Don't let your mind wander, it's too small too be out on it's own.....
unknown

I'm up and dressed what more do you want??
unknown
  #2  
Old 28-Feb-2007, 03:14
aie0 aie0 is offline
Member
 
Join Date: Dec 2004
Posts: 246
aie0 is a jewel in the roughaie0 is a jewel in the rough

Re: Overwriting a textfile


Post result files.
First thing to do when you work with binarywriter is not to use it ... until your program is completed, instead during development period - write to file through text writer. Then when you are sure that you indeed write what you want - switch to binarywriter and do the last check.
 
 

Recent GIDBlogProblems with the Navy (Officers) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
printing triangle program pepico Java Forum 2 01-Jun-2006 19:57
Textfile to array calvin22221 MS Visual C++ / MFC Forum 1 03-Aug-2005 12:03

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 18:05.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.