一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

老外编的程序(六)--目录操作

时间:2008-01-12 编辑:简简单单 来源:一聚教程网

// Takes an array of file names or directory names on the command line.    
// Determines what kind of name it is and processes it appropriately
using System;
using System.IO;
using System.Collections;
public class RecursiveFileProcessor {
    public static void Main(string[] args) {
        foreach(string path in args) {
       if(File.Exists(path)) {
           // This path is a file
           ProcessFile(path);
       }            
       else if(Directory.Exists(path)) {
           // This path is a directory
           ProcessDirectory(path);
       }
       else {
           Console.WriteLine("{0} is not a valid file or directory.", path);
       }        
        }        
    }
    // Process all files in the directory passed in, and recurse on any directories

热门栏目