Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read and write in a file

Status
Not open for further replies.

gvision

Programmer
Nov 20, 2001
14
FR
Hi,
I'm trying to read a file and then write in that one. But When I try to write in the file nothing happen.
Here's my code :

using System;
using System.Data;
using System.Drawing;
using System.IO;
using System.Web;
using System.Web.UI ;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

public abstract class example
{
private void button_click(object sender, System.EventArgs e)
{
FileStream myReadFile = new FileStream(@"c:\inetpub\ , FileMode.OpenOrCreate , FileAccess.ReadWrite);
StreamReader myStreamReader = new StreamReader(myReadFile) ;
string numeroEnvoi = myStreamReader.ReadLine() ;
int increment = int.Parse(numeroEnvoi) + 1 ;
string addIncrement = increment.ToString() ;
StreamWriter writeReadFile = new StreamWriter(myReadFile) ;
writeReadFile.Write(addIncrement) ;
}
}

Could somebody help me ??? Thanks.
 
try calling the Close() method on the writeReadFile object

StreamWriter writeReadFile = new StreamWriter(myReadFile) ;
writeReadFile.Write(addIncrement) ;
writeReadFile.Close();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top