RT   急  求高手解答!!!

解决方案 »

  1.   

    在上传文件时经常要判断文件夹是否存在,如果存在就上传文件,否则新建文件夹再上传文件判断语句为
    if (System.IO.Directory.Exists(Server.MapPath("file")) == false)//如果不存在就创建file文件夹
    {
    System.IO.Directory.CreateDirectory(Server.MapPath("file"));
    }
    System.IO.Directory.Delete(Server.MapPath("file"),true);//删除文件夹以及文件夹中的子目录,文件判断文件的存在
    if (System.IO.File.Exist(Server.MapPath("~/Back/Data.xml"))
    {
    //存在文件

    else
    {
    //不存在文件
    Directory.Create(Server.MapPath("~/Back/Data.xml"));//创建该文件
      

  2.   

    string dir="D:\\xxx\\yyy"
    if (System.IO.Directory.Exists(dir))
    {
        // 存在
    }
    else
    {
        // 不存在
    }
      

  3.   

    System.IO.File.Exists(文件路径)
    System.IO.Directory.Exists(文件夹路径)
    System.IO.Directory.GetDirectories(文件夹路径) 获取子目录System.IO.Directory
    System.IO.DirectoryInfo
      

  4.   

    using System.IO;
                
               if (Directory.Exists(@"E:\\" + 文件夹名 + "\\" + 子文件夹名))
      

  5.   

    System.IO.File.Exists(文件路径)
    System.IO.Directory.Exists(文件夹路径)
      

  6.   

    System.IO.Directory.Exists(folderPath);
    System.IO.File.Exists(filename);DirectoryInfo Folder = new DirectoryInfo(path); 
    FileInfo[] subFiles = Folder.GetFiles();