Click here to Skip to main content
15,899,754 members
Home / Discussions / C#
   

C#

 
AnswerRe: reading the data values in textfile Pin
harold aptroot22-Mar-09 6:16
harold aptroot22-Mar-09 6:16 
GeneralRe: reading the data values in textfile Pin
Nettai22-Mar-09 7:29
Nettai22-Mar-09 7:29 
GeneralRe: reading the data values in textfile Pin
harold aptroot22-Mar-09 7:41
harold aptroot22-Mar-09 7:41 
GeneralRe: reading the data values in textfile Pin
Nettai22-Mar-09 7:50
Nettai22-Mar-09 7:50 
GeneralRe: reading the data values in textfile [modified] Pin
harold aptroot22-Mar-09 8:27
harold aptroot22-Mar-09 8:27 
AnswerRe: reading the data values in textfile Pin
Jacob Dixon22-Mar-09 8:38
Jacob Dixon22-Mar-09 8:38 
GeneralRe: reading the data values in textfile Pin
Nettai22-Mar-09 8:51
Nettai22-Mar-09 8:51 
AnswerRe: reading the data values in textfile Pin
riced22-Mar-09 8:46
riced22-Mar-09 8:46 
Try this.

private void button1_Click(object sender, EventArgs e)
{
   try
   {
      string path = "c:\\Vicky\\DATAS\\matrix.txt";
      string path2 = "c:\\Vicky\\DATAS\\copy.txt";

      using (StreamReader sr = new StreamReader(path))
      using (StreamWriter sw = new StreamWriter(path2))
      {
         string line;
         while ((line = sr.ReadLine()) != null)
         {
            sw.WriteLine(line);
         }
      }
   }
   catch (Exception ex)
   {
      MessageBox.Show(ex.Message);
   }
}


You don't need to close the files/streams because using will do it for you.
Even if there is an exception.
I suggest setting a breakpoint on the while and stepping through the loop a few times.

Regards
David R

AnswerRe: reading the data values in textfile Pin
Alan N22-Mar-09 9:11
Alan N22-Mar-09 9:11 
AnswerRe: reading the data values in textfile Pin
DaveyM6922-Mar-09 9:16
professionalDaveyM6922-Mar-09 9:16 
QuestionRead all occurances of a specific tag out of an HTML file Pin
YiXiang_8922-Mar-09 4:49
YiXiang_8922-Mar-09 4:49 
AnswerRe: Read all occurances of a specific tag out of an HTML file Pin
N a v a n e e t h22-Mar-09 5:11
N a v a n e e t h22-Mar-09 5:11 
GeneralRe: Read all occurances of a specific tag out of an HTML file Pin
YiXiang_8922-Mar-09 5:27
YiXiang_8922-Mar-09 5:27 
GeneralRe: Read all occurances of a specific tag out of an HTML file Pin
N a v a n e e t h22-Mar-09 5:28
N a v a n e e t h22-Mar-09 5:28 
GeneralRe: Read all occurances of a specific tag out of an HTML file Pin
YiXiang_8922-Mar-09 5:39
YiXiang_8922-Mar-09 5:39 
GeneralRe: Read all occurances of a specific tag out of an HTML file Pin
0x3c022-Mar-09 6:05
0x3c022-Mar-09 6:05 
Questionwindows service, login - on-event application ;) Pin
orescik22-Mar-09 4:25
orescik22-Mar-09 4:25 
AnswerRe: windows service, login - on-event application ;) Pin
PIEBALDconsult22-Mar-09 4:39
mvePIEBALDconsult22-Mar-09 4:39 
GeneralRe: windows service, login - on-event application ;) Pin
orescik22-Mar-09 4:43
orescik22-Mar-09 4:43 
GeneralRe: windows service, login - on-event application ;) Pin
PIEBALDconsult22-Mar-09 15:23
mvePIEBALDconsult22-Mar-09 15:23 
AnswerRe: windows service, login - on-event application ;) Pin
0x3c022-Mar-09 4:45
0x3c022-Mar-09 4:45 
AnswerRe: windows service, login - on-event application ;) Pin
Yusuf22-Mar-09 5:06
Yusuf22-Mar-09 5:06 
Questionpartition cloning Pin
LordZoster22-Mar-09 4:13
LordZoster22-Mar-09 4:13 
AnswerRe: partition cloning Pin
Yusuf22-Mar-09 5:08
Yusuf22-Mar-09 5:08 
GeneralRe: partition cloning Pin
LordZoster22-Mar-09 5:18
LordZoster22-Mar-09 5:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.