Could be the file is still locked.  Why don't you paste the entire page of code.

On 8/10/05, Mike Belcher
<[EMAIL PROTECTED]> wrote:
> Ahhhhh it stil doenst work. A simple thing. It seems like the value of
> ServerCFG.text even though I edit it the thing is the same. I have response
> written it out also but it is the same value even after I edit it. I do see
> that Request.form("ServerCFG") has the changes. With SQL I can load all the
> textboxes with there values from the db and then make changes and hit the
> save button and it works. But for some reason with a sllly TXT file it won't
> work that way. Is there a reason why the same thing doesn't work with a file
> as it does with sql server? Lots of time on this thing............. not
> working..... :(
> 
> -----Original Message-----
> From: [email protected]
> [mailto:[EMAIL PROTECTED] On Behalf Of Dean Fiala
> Sent: Tuesday, August 09, 2005 10:49 PM
> To: [email protected]
> Subject: Re: [AspNetAnyQuestionIsOk] .TxtFIle says its saved but no change
> 
> You see the problem,
> 
> Page_load gets called before your update code.  Page_load always gets
> called when you postback, hence you never update the file, you always
> overwrite the new value with the old value.
> 
> 
> Do something like...
> 
> If Not Page.IsPostBack then
>   Dim FILE_NAME As String = "D:\server.cfg"
> 
>              Dim objReader As New System.IO.StreamReader(FILE_NAME)
> 
>            ServerCFG.Text = objReader.ReadToEnd
> 
>              objReader.Close()
> 
> End If
> 
> On 8/9/05, Mike Belcher <[EMAIL PROTECTED]>
> wrote:
> >             Dim FILE_NAME As String = "D:\server.cfg"
> >
> >             Dim objReader As New System.IO.StreamReader(FILE_NAME)
> >
> >             ServerCFG.Text = objReader.ReadToEnd
> >
> >             objReader.Close()
> >
> >
> >
> > That loads the file back into the textbox on page load............. on the
> > page is up there is a button that you can click to save the changes which
> > has this in it:
> >
> >
> > Private Sub ButtonSaveChanges_Click(ByVal sender As System.Object, ByVal e
> > As System.EventArgs) Handles ButtonSaveChanges.Click
> >
> >
> >
> >         Dim fs As FileStream = File.Create("D:\server.cfg")
> >         Dim sw As StreamWriter = New StreamWriter(fs)
> >
> >
> >         Try
> >             sw.Write(ServerCFG.Text)
> >             sw.Close()
> >             fs.Close()
> >         Catch ex As Exception
> >             Response.Write(ex.Message)
> >         End Try
> >         LabelServerCFG.Text = "Server CFG has been Updated"
> >
> >     End Sub
> >
> >
> >
> >
> >
> >
> >
> >
> > I tried this  once and it actually saved
> > something...............................
> >
> >
> >
> > Private Sub ButtonSaveChanges_Click(ByVal sender As System.Object, ByVal e
> > As System.EventArgs) Handles ButtonSaveChanges.Click
> >
> >
> >
> >         Dim fs As FileStream = File.Create("D:\server.cfg")
> >         Dim sw As StreamWriter = New StreamWriter(fs)
> >
> > strTest = Request.Form("ServerCFG")
> >
> >
> >         Try
> >             sw.Write(strTest)
> >             sw.Close()
> >             fs.Close()
> >         Catch ex As Exception
> >             Response.Write(ex.Message)
> >         End Try
> >         LabelServerCFG.Text = "Server CFG has been Updated"
> >
> >     End Sub
> >
> >
> >
> >
> >
> >
> >
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Dean Fiala
> > Sent: Tuesday, August 09, 2005 7:01 PM
> > To: [email protected]
> > Subject: Re: [AspNetAnyQuestionIsOk] .TxtFIle says its saved but no change
> >
> > Are you reloading during your postback? Let's see your page_load code.
> >
> > On 8/9/05, Mike Belcher <[EMAIL PROTECTED]>
> > wrote:
> > > I have trace on with this particular page. I I look at the Form
> Collection
> > > for this textbox it shows the changes in it after postback. But I
> > > response.write the value of the textbox and it shows the old value. I
> > guess
> > > this is whats happening........ how to fix this?
> > >
> > > -----Original Message-----
> > > From: [email protected]
> > > [mailto:[EMAIL PROTECTED] On Behalf Of Mike Belcher
> > > Sent: Tuesday, August 09, 2005 4:44 PM
> > > To: [email protected]
> > > Subject: RE: [AspNetAnyQuestionIsOk] wow solve one issue then
> > > another.TxtFIle says its saved but no change
> > >
> > > See that is the mystifying thing there. No error and if you look on the
> > hard
> > > drive itself the file has been saved as the time changes. But the edits
> > made
> > > in the textbox do not seem to be reflected in the saved file. It remains
> > the
> > > same as when it was loaded. I do this same type of stuff with db fields
> a
> > > ton and the changes are saved but for some reason im not getting the
> > edited
> > > changes on the file in this case.
> > >
> > > -----Original Message-----
> > > From: [email protected]
> > > [mailto:[EMAIL PROTECTED] On Behalf Of David Renz
> > > Sent: Tuesday, August 09, 2005 4:27 PM
> > > To: [email protected]
> > > Subject: Re: [AspNetAnyQuestionIsOk] wow solve one issue then
> > > another.TxtFIle says its saved but no change
> > >
> > > try to do a catch to see if you are getting an error
> > >
> > > Dim fs As FileStream = File.Create("D:\server.cfg")
> > > Dim sw As StreamWriter = New StreamWriter(fs)
> > > try
> > > sw.Write(ServerCFG.Text)
> > > sw.Close()
> > > fs.Close()
> > > catch ex as Exception
> > >     lblMessage.Show
> > >    lblMessage.Text = ex.Message
> > > end try
> > >
> > >
> > >
> > >
> > > >>> [EMAIL PROTECTED] 08/09/2005 1:19:59
> > > PM >>>
> > >
> > > Permissions work........... I have a page now that loads a cfg file
> > > from the
> > > disk and puts it in a textbox control. This works great. I then have a
> > > save
> > > changes button that will save the contents of the textbox back to the
> > > file.
> > > The problem is that I make changes and save and when you check the file
> > > it's
> > > the same. I have looked on the disk and the date and time change so it
> > > is
> > > writing it but apparently no the edited changes. Here is the code.
> > >
> > >
> > >
> > > Opening routine.
> > >
> > >             Dim FILE_NAME As String = "D:\server.cfg"
> > >
> > >             Dim objReader As New System.IO.StreamReader(FILE_NAME)
> > >
> > >             ServerCFG.Text = objReader.ReadToEnd
> > >
> > >             objReader.Close()
> > >
> > >
> > > Saving Routine
> > >
> > >         Dim fs As FileStream = File.Create("D:\server.cfg")
> > >         Dim sw As StreamWriter = New StreamWriter(fs)
> > >         sw.Write(ServerCFG.Text)
> > >         sw.Close()
> > >         fs.Close()
> > >
> > >
> > > As I said it all works and even shows that the file has been saved but
> > > the
> > > things I changed in the textbox don't seem to be there.
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > [Non-text portions of this message have been removed]
> > >
> > >
> > >
> > >
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> > --
> > Dean Fiala
> > Very Practical Software, Inc
> > http://www.vpsw.com
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> 
> 
> --
> Dean Fiala
> Very Practical Software, Inc
> http://www.vpsw.com
> 
> 
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
> 
> 


-- 
Dean Fiala
Very Practical Software, Inc
http://www.vpsw.com


------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12h4gtptj/M=362335.6886445.7839731.1510227/D=groups/S=1705006764:TM/Y=YAHOO/EXP=1123709248/A=2894361/R=0/SIG=13jmebhbo/*http://www.networkforgood.org/topics/education/digitaldivide/?source=YAHOO&cmpgn=GRP&RTP=http://groups.yahoo.com/";>In
 low income neighborhoods, 84% do not own computers. At Network for Good, help 
bridge the Digital Divide!</a>.</font>
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to