' Create a file by passing an encoding ' expC1 String ' expC2 File ' expC3 Encoding ' expL1 If we log the error if the file cannot be deleted Public Function CreateFileEncoding(ByVal tcString As String, ByVal tcFile As String, _ ByVal tcEncoding As System.Text.Encoding, ByVal tlLogError As Boolean) As Boolean Dim llSuccess As Boolean = False Dim lnCounter As Integer = 0 Dim lnDelay As Integer = 250 Dim lnRetry As Integer = 8 Dim loFileStream As FileStream Dim loStreamWriter As IO.StreamWriter For lnCounter = 1 To lnRetry Try loFileStream = New FileStream(tcFile, FileMode.Create) loStreamWriter = New StreamWriter(loFileStream, tcEncoding) loStreamWriter.Write(tcString) loStreamWriter.Close() loFileStream.Close() llSuccess = True Exit For Catch loError As Exception ' If we have not reached the maximum tries of 8, we retry If lnCounter < 8 Then ' Wait for a timeout before retrying System.Threading.Thread.Sleep(lnDelay) Continue For End If ' If we log the error If tlLogError Then ' Get the proper definition as per the current scope If oProcess Is Nothing Then oApp.ErrorSetup(loError) Else oProcess.ErrorSetup(loError) End If End If End Try Next Return llSuccess End FunctionSo, it happens at the loStringBuilder.ToString() location.