Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Private Sub btnAdd_Click(sender As System.Object, e As System.EventArgs) Handles

ID: 3640373 • Letter: P

Question

Private Sub btnAdd_Click(sender As System.Object, e As System.EventArgs) Handles btnAdd.Click

Dim myReader As IO.StreamReader = IO.File.OpenText("C:Visual Studio 2010 estData.txt")
Dim sum As Integer = 0
Dim num As Integer


Try
myReader = IO.File.OpenText("C:Visual Studio 2010 estData.txt")
Catch ex As IO.DirectoryNotFoundException
MessageBox.Show(" Directory not found, " & ex.Message & "By: ")
Catch exc As IO.DriveNotFoundException
MessageBox.Show(" File cannot be found, " & exc.Message & "By:")
End Try

Explanation / Answer

Imports System.IO Module Module1 Sub Main() Try ' Specify a directory name that does not exist for this demo. Dim dir As String = "c:8fe9lk" ' If this directory does not exist, a DirectoryNotFoundException is thrown ' when attempting to set the current directory. Directory.SetCurrentDirectory(dir) Catch ex As System.IO.DirectoryNotFoundException ' Let the user know that the directory did not exist. Console.WriteLine("Directory not found: " + ex.Message) End Try End Sub End Module

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote