文档介绍:IT-Homer 专栏
成功是优点的发挥,失败是缺点的积累! 不为失败找理由,只为成功找
方法……
C#读取文件夹中的文件操作浅析
2010-01-03 13:58 433人阅读评论(0) 收藏举报
C#读取文件夹中的文件操作浅析 C#读取文件夹中的文件操作是怎么样子的呢?那么本文就向你介绍这方面的内
容,希望对你有所帮助。  
C#读取文件夹的操作是如何进行的呢?首先让我们来看啊可能:读出一个文件夹中的所有文件(文件数从0个
到N多不定).没有文件返回假.
都是ascii码文件.
读每个文件的前一部分至出现第一个/s./s/r 为止.
读出来放后放至string[] filetsr中. 
1. strFiles = (@"c:/Import");
2. foreach(string strFile in strFiles)
3. {
4. (strFile,("Import","Rubbish_Files"));
5.
6. //上面这句换为你的C#读取文件夹处理。
7.
8. }
试试看C#读取文件夹的代码吧,没来得及调试,有问题自己改改吧!
1. using System;
2. using ;
3.
4. class Test
5. {
6. public static void Main()
7. {
8. try
9. {
10. // Only get files that begin with the letter "c."
11. int i=0;
12. string[] dirs = (@"c:/", "c*");
13. ("The number of files starting with c is {0}.", );
14. string[] filetsr=new String[];
15. foreach (string dir in dirs)
16. {
17. FileStream fs = new FileStream(dir,);
18. byte[] readBuf=new byte[];
19. (readBuf,0,);
20.
21. data = (readBuf);
22. if (("/s./s/r") > -1)
23. {
24. i++;
25. filestr[i]=(("/s./s/r") -1)
26. }
27.
28. }
29. }
30. catch (Exception e)