Problem when reading DBF files
-
Hi all, I've got a small problem when i tried to read DBF files. I'm using OleDb provider. The problem is i just could read dbf files that have the length of filename which are less than or equal to 8 (not including extension). I can't understand this. Thanks a lot
-
Hi all, I've got a small problem when i tried to read DBF files. I'm using OleDb provider. The problem is i just could read dbf files that have the length of filename which are less than or equal to 8 (not including extension). I can't understand this. Thanks a lot
DBF files are from the age of DOS, hence the 8.3 name limitation. Apparently no one cared to update it, and I doubt they will now as it really shouldn't be used anymore. There might be a decent solution, but my workaround was copying the file to a temp location to get the legal name.
-
DBF files are from the age of DOS, hence the 8.3 name limitation. Apparently no one cared to update it, and I doubt they will now as it really shouldn't be used anymore. There might be a decent solution, but my workaround was copying the file to a temp location to get the legal name.
Hi, what is database connection string your using. Check the connection strain properly. Regards, Kiran Kumar Singani The Dream is not what you see in sleep........Dream is the thing which does not let you sleep
-
Hi all, I've got a small problem when i tried to read DBF files. I'm using OleDb provider. The problem is i just could read dbf files that have the length of filename which are less than or equal to 8 (not including extension). I can't understand this. Thanks a lot
Hi. By all means, you should continue to find out why the driver thinks it's a DOS program! But if the driver turns out to be inflexible, you can adapt the file name to the mangled "FILE~01.DBF" type of format. I've been trying to post the code to you all day, but there's something about the message that causes the Code Project to time out. I'm reduced to hinting! It's a function in Kernel32 called GetShortPathName(), and I found the C# example myself using Google when I was in a similar situation. If you have trouble finding it, we can figure out some other way of getting you the code. Hope this helps. Evan
-
Hi, what is database connection string your using. Check the connection strain properly. Regards, Kiran Kumar Singani The Dream is not what you see in sleep........Dream is the thing which does not let you sleep
Hi Kiran Kumar Singani, Thanks for your answer The ConnectionString I'm using is "Provider=Microsoft.Jet.OLEDB.4.0; Data Source= " + directoryName + "; Extended Properties=dBASE IV; User ID=; Password=;" It just works fine with all dbf files that has the length of filename less than or equal to 8. Thanks again
-
Hi. By all means, you should continue to find out why the driver thinks it's a DOS program! But if the driver turns out to be inflexible, you can adapt the file name to the mangled "FILE~01.DBF" type of format. I've been trying to post the code to you all day, but there's something about the message that causes the Code Project to time out. I'm reduced to hinting! It's a function in Kernel32 called GetShortPathName(), and I found the C# example myself using Google when I was in a similar situation. If you have trouble finding it, we can figure out some other way of getting you the code. Hope this helps. Evan
Hi Evan, The ConnectionString i'm using to read *dbf files is "Provider=Microsoft.Jet.OLEDB.4.0; Data Source= " + directoryName + "; Extended Properties=dBASE IV; User ID=; Password=;"" My current solution is copying that DBF file to temporary DBF file which has a legal name (length of filename <= 8), processing on the temporary file and deleting it after finishing. If you have a better solution, Please let me know. Thanks a lot.
-
Hi Evan, The ConnectionString i'm using to read *dbf files is "Provider=Microsoft.Jet.OLEDB.4.0; Data Source= " + directoryName + "; Extended Properties=dBASE IV; User ID=; Password=;"" My current solution is copying that DBF file to temporary DBF file which has a legal name (length of filename <= 8), processing on the temporary file and deleting it after finishing. If you have a better solution, Please let me know. Thanks a lot.
[DllImport("Kernel32", CharSet = CharSet.Auto)]
static extern Int32 GetShortPathName(
String path, // input string
StringBuilder shortPath, // output string
Int32 shortPathLength); // StringBuilder.Capacity
public static string ConvertLongPathToShort(string longPathName)
{
StringBuilder shortNameBuffer;
int size;shortNameBuffer = new StringBuilder(); size = GetShortPathName(longPathName, shortNameBuffer, shortNameBuffer.Capacity); if(size >= shortNameBuffer.Capacity) { shortNameBuffer.Capacity = size + 1; GetShortPathName(longPathName, shortNameBuffer, shortNameBuffer.Capacity); } return shortNameBuffer.ToString();
}
-
Hi Evan, The ConnectionString i'm using to read *dbf files is "Provider=Microsoft.Jet.OLEDB.4.0; Data Source= " + directoryName + "; Extended Properties=dBASE IV; User ID=; Password=;"" My current solution is copying that DBF file to temporary DBF file which has a legal name (length of filename <= 8), processing on the temporary file and deleting it after finishing. If you have a better solution, Please let me know. Thanks a lot.
Your solution will work, though copying is extra effort. The solution I proposed is to get an 8.3 name from Windows. This name is a direct substitute for the long name of the file. It will have a tilde (~) character and a number in it, and can be used to access the DBF file you want. I've had the darndest time putting in the code, and have found that it's possible to put in when the code is by itself, without a message. Therefore, the code for the function is separate. Good luck. Evan
-
Your solution will work, though copying is extra effort. The solution I proposed is to get an 8.3 name from Windows. This name is a direct substitute for the long name of the file. It will have a tilde (~) character and a number in it, and can be used to access the DBF file you want. I've had the darndest time putting in the code, and have found that it's possible to put in when the code is by itself, without a message. Therefore, the code for the function is separate. Good luck. Evan