File.Exist(string path)
//文件读写
FileStream fs=new FileStream(filename, FileMode.Create);
BinaryWriter bw=new BinaryWriter(fs);
bw.Write("OK");
bw.Flush();
bw.Close();
fs.Close();
if
(!Directory.Exists(sPath))
{
Directory.CreateDirectory(sPath);
}
C#遍历指定文件夹
DirectoryInfo TheFolder=new DirectoryInfo(folderFullName);
//遍历文件夹
foreach(DirectoryInfo NextFolder in TheFolder.GetDirectories())
this.listBox1.Items.Add(NextFolder.Name);
//遍历文件
foreach(FileInfo NextFile in TheFolder.GetFiles())
this.listBox2.Items.Add(NextFile.Name);
//遍历文件夹
foreach(DirectoryInfo NextFolder in TheFolder.GetDirectories())
this.listBox1.Items.Add(NextFolder.Name);
//遍历文件
foreach(FileInfo NextFile in TheFolder.GetFiles())
this.listBox2.Items.Add(NextFile.Name);
//遍历文件或者文件夹
DirectoryInfo. GetFileSystemInfos():获取指定目录下(不包含子目录)的文件和子目录,返回类型为FileSystemInfo[],支持通配符查找;