Hi...
I have a code that works well on my computer and some pc's but on other pc's it gives me the following exception:
Microsoft Jet Database engine could not find the object 'yahoo.csv' make sure the object exists and that you spell its name and path correctly.
Source Code:
FileInfo file = new System.IO.FileInfo(filename);string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +"Data Source=\"" + file.DirectoryName +"\";Extended Properties='text;HDR=Yes;FMT=Delimited(,)';";OleDbConnection conn = new System.Data.OleDb.OleDbConnection(ConnectionString);OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(string.Format("SELECT * FROM [" + file.Name + "]", file.Name), conn);
conn.Open();
//some other code goes here and has no effect on the exception.
conn.Close();
I traced the code and i think the problem could be on the line i highlited above.
Updated Question
I think i have found something concerning the error;
when i trace my code, this is what i get from the line that contains "file.DirectoryName" it says file.Directory= "C:\\Program Files\\Common Files\\Microsoft Shared\\DevServer\\10.0"
i discoverd that i only get this from computers that have been partioned, whereas computers that haven't been partioned it gives me the correct file.DirectoryName.
How do i then solve this error/Exception?
Loading


Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 10, 2011, 12:58 PM EDT
Did you verify the path and file name is correct, may be the file name is embedded with periods.
Please do not forget to mark "Accepted Answer".
Mahesh ChandRank #1 · 393.4K reputationPosted Oct 10, 2011, 1:06 PM EDT
Get the file name in debugger and copy in your Windows Explorer and see if the file path is correct. It seems like there is an issue with the correct path.
Andile Choko52 reputationPosted Oct 10, 2011, 1:35 PM EDT
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 10, 2011, 1:44 PM EDT
Please do not forget to mark "Accepted Answer".
Andile Choko52 reputationPosted Oct 10, 2011, 3:13 PM EDT
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 10, 2011, 4:05 PM EDT
Please do not forget to mark "Accepted Answer".
Andile Choko52 reputationPosted Oct 16, 2011, 12:36 PM EDT
when i trace my code, this is what i get from the line that contains "file.DirectoryName" it says file.Directory= "C:\\Program Files\\Common Files\\Microsoft Shared\\DevServer\\10.0"
i discoverd that i only get this from computers that have been partioned, whereas computers that haven't been partioned it gives me the correct file.DirectoryName.
How do i then solve this error/Exception?