Hello,
I'm debugging a VB.NET code that is supposed to create a logfile for a conversion program if any errors are found when converting the data and transferring it to a MS SQL Server database.
I keep getting an error stating "SecurityException was unhandled". I was told that the reason why this occurred was because of the permission access in windows 7 as it does not allow programs to write to the windows root directory (C:).
So I implemented a code to get the file path of the user's appdata directory and store the program logs in that location but the same error about the security exception keeps coming up.
Below is the code currently being debugged:
Sub CreateLog2()
Dim log As Scripting.FileSystemObject
Dim logfile As Scripting.TextStream
Dim logf As String
Dim appData As String = GetFolderPath(SpecialFolder.ApplicationData)
'Gets folder path of appdata as it varies on different machine
logf = appData
log = New Scripting.FileSystemObject
logfile = log.CreateTextFile(logf, True) 'At this line it gives the error
logfile.WriteLine("MISSING ADMISSION OR DISCHARGE DATES FOUND")
logfile.WriteLine("MED_REC_NO")
logfile.Close()
End Sub
Thank you for your time and your response :)