dear i have this code
StreamWriter stname = new StreamWriter("d:\\abc.text");
string text = t11.Text;
stname.WriteLine(text);
stname.Close();
StreamWriter stno = new StreamWriter("d:\\abc.text");
string no = lpnu1.Text;
stno.WriteLine(no);
stno.Close();
but in output file only no is written there is no name .but if i remove stno streamwriter then it writes name.
how i can write both name and no in same file.both these are on button click event. i not know much c#.
Loading
VulpesPosted Aug 12, 2012, 11:16 AM
To deal with that and the first problem, make the highlighted changes as follows:
private void pt_Click(object sender, EventArgs e)
{
StreamWriter date = new StreamWriter("d:\\abc.text", true);
string dates = Convert.ToString(dp1.Value) + " ";
date.Write(dates);
date.Close();
StreamWriter stno = new StreamWriter("d:\\abc.text",true);
string no = lpnu1.Text + " ";
stno.Write(no);
stno.Close();
StreamWriter stname = new StreamWriter("d:\\abc.text", true);
string text = t11.Text + " ";
stname.WriteLine(text); // make sure next entries will start on a new line
stname.Close();
// button1.Hide();
// pt.Hide();
MessageBox.Show("data is printed");
}
VulpesPosted Aug 13, 2012, 2:35 PM
http://msdn.microsoft.com/en-us/library/6he9hz8c.aspx
To allow specifically for A4 paper and to catch the exception if something goes wrong when attempting to print, you'll need to change the printButton_Click handler as follows:
ta muPosted Aug 13, 2012, 10:37 AM
a dialog. when print button is pressed a printout comes out of printer.
but no printer is installed with my pc. exception handling for printer is necessery..
i want to print of size a4
ta muPosted Aug 12, 2012, 4:33 PM
ta muPosted Aug 12, 2012, 10:36 AM
datenoname means no space between them but i want ( date no name) code is again
private void pt_Click(object sender, EventArgs e)
{
StreamWriter date = new StreamWriter("d:\\abc.text" );
string dates = Convert.ToString(dp1.Value);
date.Write(dates);
date.Close();
StreamWriter stno = new StreamWriter("d:\\abc.text",true);
string no = lpnu1.Text;
stno.Write(no);
stno.Close();
StreamWriter stname = new StreamWriter("d:\\abc.text", true);
string text = t11.Text;
stname.Write(text);
stname.Close();
// button1.Hide();
// pt.Hide();
MessageBox.Show("data is printed");
}
sesond problem is when i close aplication my data is in file but when run it again
and enter data my old data get lost but i whant evry time whenever i enter data
all data remain in file.
VulpesPosted Aug 9, 2012, 1:57 PM