beginner

beginner

  • NA
  • 3
  • 0

syntax to modify code from vc++.net to c#.net

Oct 11 2007 3:47 AM
Hi,
  Earlier i was working with VC++.net code to read contents of a file & copy it to another file. Now i want to perform the same task using c#.net. pls help me.. The code in vc++.net was

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
         if (openFileDialog1.ShowDialog() == DialogResult.OK)
         {
         String^ s;
         FileStream   ^stmGrades = gcnew FileStream("CFG.txt",FileMode::Create,  FileAccess::Write);
         StreamWriter ^bnwGrades = gcnew StreamWriter(stmGrades);

         // Create a FileInfo object based on the file
         FileInfo ^fleLoan = gcnew FileInfo(openFileDialog1->FileName);
         // Open the file
         StreamReader ^stmLoan = fleLoan->OpenText();

        //Read each line in the selected file & assign/store that line to string pointer s till null or EOF  is reached
       while(s = stmLoan->ReadLine())   // THIS LINE I WANT TO MODIFY TO C#
         {
               bnwGrades->WriteLine();   //write the line in the created file
             }
         }
         stmLoan->Close();
         bnwGrades->Close();
     }


Answers (4)