Convert a text file to uppercase Learn programming Visual Basic (VB.net)

Lesson:

File Management


Exercise:

Convert a text file to uppercase 17


Objetive:

Write a program to read a text file and dump its content to another file, changing the lowercase letters to uppercase.

You must deliver only the ".cs" file, with you name in a comment.


Code:

Imports System
Imports System.IO
Namespace FileLowerCaseToUpperCase
    Class Program
        Private Shared Sub Main()
            Console.Write("Enter name file: ")
            Dim fileName As String = Console.ReadLine()

            If File.Exists(fileName) Then
                Dim fileRw As StreamReader = File.OpenText(fileName)
                Dim fileWr As StreamWriter = File.CreateText(fileName & ".dat")
                Dim line As String

                Do
                    line = fileRw.ReadLine()
                    If line IsNot Nothing Then fileWr.WriteLine(line.ToUpper())
                Loop While line IsNot Nothing

                fileRw.Close()
                fileWr.Close()
            End If
        End Sub
    End Class
End Namespace