阅读现有内容,以及每当文本文件进入文件夹时...请帮助 [英] Read existing and whenever a text file arrives in a folder ...Please Help

查看:53
本文介绍了阅读现有内容,以及每当文本文件进入文件夹时...请帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要C#代码来读取文件夹中已经存在的excel格式的文件,以及到达文件夹中的文件并将数据插入数据库中的表中.文件以"|"分隔.

任何帮助将不胜感激.....:)

Hi,

I need C# code to read files in excel format that are already there in a folder and also the files that arrive in the folder and insert the data into a table in the database.The files are delimited by "|".

Any Help will be highly appreciated..... :)

推荐答案

以下是FileSystemWatcher的示例
C#:使用FileSystem Watcher监视文件或目录的应用程序 [ Excel数据读取器-读取.NET中的Excel文件 [ ^ ]

EPPlus [ ^ ]

希望您能开始...

问候
Espen Harlinn
Here is an example for FileSystemWatcher
C#: Application to Watch a File or Directory using FileSystem Watcher[^]

Two excellent libraries for dealing with Excel:
Excel Data Reader - Read Excel files in .NET[^]

EPPlus[^]

It will hopefully et you started ...

Regards
Espen Harlinn


您只需要跟踪文件是否已被读入DB.

为此,您需要执行以下操作:-



1.首先在表中创建一列(字段),以保存已读取的文件名
可能您已经有这样的领域.

2.每当您将文件复制到DB时,首先检查表中是否尚未存在

You just need to keep track whether file is already read into DB or not.

For this purpose you need do :--



1. first create a column(field) to your table to hold the file name which are already read
probably you already have such field.

2. Whenever you copy a file to DB first check if it is not already in the table

if yes
     then do nothing just go next in the loop

if not
     put the absolute path of file into DB
     copy the file into DB in your own way.


这篇关于阅读现有内容,以及每当文本文件进入文件夹时...请帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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