2 Replies - 6575 Views - Last Post: 20 January 2012 - 06:34 AM

#1 cheekangteh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 04-December 11

how can i overwrite a text file in window mobile 6 professional

Posted 20 January 2012 - 04:48 AM

hi i am facing overwriting file in window mobile 6 professional.

bellow are my code.

when the system start loading:


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim line As String
        Dim Lat As StreamReader = New StreamReader("\Program Files\please_must_be_ok\Resources\contact1.txt")
        line = Lat.ReadToEnd()
        TextBox1.Text = line
        Lat.Close()
    End Sub




the system will automatic load the file contact1.txt contact number to TextBox1.Text
if the user want to change the contact display at TextBox1.Text, the user required key the new contact number at TextBox1.Text, then click the Button1 to save the contact number to file "contact1.text"

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


        Dim Lat As StreamWriter = New StreamWriter("\Program Files\please_must_be_ok\Resources\contact1.txt")
        Lat.WriteLine(TextBox1.Text)
        Lat.Close()

    End Sub





my problem now is, i can't overwrite the contact number in file "contact1.txt"


kindly advice, how can i overwrite the "contact1.txt" file in window mobile 6 professional.

thank a lot

Is This A Good Question/Topic? 0
  • +

Replies To: how can i overwrite a text file in window mobile 6 professional

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: how can i overwrite a text file in window mobile 6 professional

Posted 20 January 2012 - 06:05 AM

So what happens? By default, the StreamWriter class will overwrite the file if it exists. There's nothing special that you have to do to make it overwrite.
Was This Post Helpful? 0
  • +
  • -

#3 cheekangteh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 04-December 11

Re: how can i overwrite a text file in window mobile 6 professional

Posted 20 January 2012 - 06:34 AM

Hi sorry,

After i double checking the file.

The file is overwrite after i click the button (when the program is still running), but after i close the program and run it again, it just show me the old contact without change to new contact that overwrite just now.

kindly advice how can i permanent overwrite a text file.

thanks a lot.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1