File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -236,6 +236,10 @@ Public Function DetectEncoding(filePath As String) As String
236236 fileNum = FreeFile
237237 Open filePath For Binary Access Read As #fileNum
238238
239+ If LOF(fileNum) = 0 Then
240+ DetectEncoding = "ANSI"
241+ Exit Function
242+ End If
239243 ' Read up to the first 1024 bytes
240244 byteCount = IIf (LOF(fileNum) < 1024 , LOF(fileNum), 1024 )
241245 ReDim byteData(0 To byteCount - 1 )
@@ -429,12 +433,12 @@ End Sub
429433Public Sub OpenStream (filePath As String )
430434Attribute OpenStream.VB_Description = "Opens a stream over a text file."
431435 If P_PATH <> filePath Then
436+ CreateSubFolders filePath
432437 If P_AUTODETECTENCODING Then
433438 P_DETECTEDENCODING = DetectEncoding(filePath)
434439 P_UTF8ENCODED = (P_DETECTEDENCODING = "UTF-8" )
435440 End If
436441 FileHandled = FreeFile
437- CreateSubFolders filePath
438442 Open filePath For Binary As #FileHandled
439443 P_ISOPENSTREAM = True
440444 P_STREAMLENGTH = LOF(FileHandled)
You can’t perform that action at this time.
0 commit comments