Is anything wrong with this code? I ask because in the past, I included the text file with the installer. In an attempt to simplify the installer, I decided to make the app generate the text file and put it where it needs to go.
Here's the code (simplified)
First it creates the directory folder-
Sub CreateCriticalFolder()
Try
If (Directory.Exists(x.myCriticalFolder)) Then
'MsgBox("Critical Folder Already Exists ")
Else
Directory.CreateDirectory(x.myCriticalFolder)
End If
Catch E As Exception
MsgBox("Error creating directory")
MsgBox("Error: {0}", E.Message)
End Try
End Sub
Then it creates the text file
Public Shared Sub CreateLocationsAndCallTypes()
Dim path As String = myCriticalFolder & "Locations and Call Types.txt"
If File.Exists(path) = True Then
Exit Sub
ElseIf File.Exists(path) = False Then
' Create a file to write to.
Dim sw As StreamWriter = File.CreateText(path)
sw.WriteLine("Sample Line of text #1")
sw.WriteLine("Sample Line of text #2")
sw.WriteLine("Sample Line of text #3")
sw.WriteLine("Sample Line of text #4")
sw.Close()
End If
End Sub
FWIW, the myCriticalFolder is located here- Environment.SpecialFolder.LocalApplicationData
Users are reporting their "Locations and Call Types.txt" getting wiped out on updates. Sone users are reporting they are unable to edit this file through the app, like it's locked or something.
The code seems to make sense. Is there anything strange with it? Look normal?