asked on
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For Each q As String In Directory.GetFiles("C:\", "InSight_Customized_View_Download*.csv")
Dim FILE_NAME As String = q
Dim filename As String = "C:\Error Log\Error Log.txt"
Dim TextLine As String
If File.Exists(FILE_NAME) = True Then
'A bunch of code that executes if file exists. This runs without any issue.
Else
'Dim sb As New StringBuilder()
'Using objReader2 As New StreamReader(filename)
' sb.AppendLine(objReader2.ReadToEnd)
' sb.AppendLine(Today & vbTab & vbTab & "File Does Not Exist")
' objReader2.Close()
'End Using
'Dim objWriter As New StreamWriter(filename)
'objWriter.Write(sb.ToString)
'objWriter.Close()
Try
' Following is better approch, it will append data to file
Dim objWriter As New StreamWriter(filename, True)
objWriter.Write(Today & vbTab & vbTab & "File Does Not Exist")
objWriter.Close()
MsgBox("File Does Not Exist")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
Next
Me.Close()
End Sub
ASKER
ASKER
The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.
TRUSTED BY