将CSV文件导入到C#.net应用程序 [英] Importing a csv file to c#.net application

查看:71
本文介绍了将CSV文件导入到C#.net应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OleDbConnection DBConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/carrier411_header_example.csv") + ";Extended Properties='Text;HDR=Yes;'");


错误:
''D:\ Anand \ Projects \ ExcelGV \ carrier411_header_example.csv''不是有效的路径.确保路径名拼写正确,并且已连接到文件所在的服务器.

但是实际上所有路径都是正确的,我上传了CSV文件以进行读取.为什么无法建立与csv文件的连接?


ERROR:
''D:\Anand\Projects\ExcelGV\carrier411_header_example.csv'' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.

But actually all the path was correct and I uploaded CSV file to read. Why it is unable to establish a connection to a csv file?

推荐答案

请确保您确实具有访问此文件夹的权限.
Make sure you do have permissions to access this folder.


尝试两件事:
1.确保文件位于以下路径:''D:\ Anand \ Projects \ ExcelGV \ carrier411_header_example.csv''

2.确保已配置适当的权限,以便您的代码可以访问该文件.为了进行简单的测试,请提供对所有人"的访问权限,并查看情况如何.如果可行,那么您需要根据其他设置为您的应用程序找到适当的权限.
Try 2 things:
1. Make sure file exists at following path: ''D:\Anand\Projects\ExcelGV\carrier411_header_example.csv''

2. Make sure you have configured proper permissions such that your code can access the file. For simple testing, provide access to ''Everyone'' and see how things go. If it works then you need to figure out the appropriate permission for your application based on other settings.


解决方案:
快速CSV阅读器
塞巴斯蒂安·洛里昂(Sebastien Lorion)

使用ADO .NET JET提供程序的速度慢且不稳定--有时由于没有明显的原因而失败.就像需要Windows注册表调整一样.
Solution:
A Fast CSV Reader
By Sebastien Lorion

Using ADO .NET JET provider is much slower and unstable --- it sometimes fails for no obvious reason. It''s like a windows registry tweak is needed.


这篇关于将CSV文件导入到C#.net应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆