如何从给定目录动态读取文件 [英] how to read files dynamically from given directory

查看:68
本文介绍了如何从给定目录动态读取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我创建了一个Windows应用程序。在这个应用程序中我给了directory.In这个目录下所有的csv文件都在那里。如何动态地读取所有csv文件。完成循环并等待另一个csv文件。就像这个运行连续模式。请告诉我解决这个问题。

谢谢



问候,

raju

Hi,
I am create one windows application.in this application i am given directory.In this directory all csv files is there.How to read all csv file take one by one dynamically.After Complete cycle and wait for another csv file.like this run continuous mode.please tell me solve this problem.
thank you

regards,
raju

推荐答案

阅读目录



Reading Directory

string[] fileList = Directory.GetFiles( @"Z:\My Documents\", "*.csv");





阅读文件



1.



Reading files

1.

var reader = new StreamReader(File.OpenRead(@"C:\test.csv"));



2.


2.

using (var rd = new StreamReader("filename.csv"))
{
    while (!rd.EndOfStream)
    {



3.


3.

var contents = File.ReadAllText(filename)





尝试在Google / CP上探索更多内容



谢谢

--RA



Try to explore more on Google/CP

Thanks
--RA


检查这个答案:



http://stackoverflow.com/questions/5840443 / how-to-read-all-files-inside-specific-folder [ ^ ]
Check this answer out:

http://stackoverflow.com/questions/5840443/how-to-read-all-files-inside-particular-folder[^]


这篇关于如何从给定目录动态读取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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