我没有完全找出问题所在,但很明显,长文件名造成了问题,所以这就是我所做的
ConnString = "Provider=Microsoft.Jet.OleDb.4.0; Data Source = " & System.IO.Path.GetDirectoryName(strFileName) & "; Extended Properties = ""Text;HDR=YES;FMT=Delimited"""
'=================================== OleDB Supports fixed length file name. Handle long file names'
Dim OldFileName As String = System.IO.Path.GetFileName(strFileName)
Dim NewFileName As String = Guid.NewGuid().ToString().Substring(0, 10) + System.IO.Path.GetExtension(OldFileName)
Dim rootPath As String = System.IO.Path.GetDirectoryName(strFileName) + "/"
'Rename file name'
My.Computer.FileSystem.RenameFile(rootPath + OldFileName, NewFileName)
strFileName = rootPath + NewFileName
'===================================='
Dim strQuery As String
strQuery = "SELECT * FROM [" & System.IO.Path.GetFileName(strFileName) & "]"
'Revert rename file name'
'===================================================================='
My.Computer.FileSystem.RenameFile(rootPath + NewFileName, OldFileName)
strFileName = rootPath + OldFileName
'===================================================================='
我只是用新的 Guid 重命名了文件,而在将数据重命名回原始文件名后检索数据。
这不是我想要的,我仍在寻找更好的解决方案。如果有人找到,请发布。
谢谢