判断文件夹/文件是否存在
public static void fileOperation() {
string path = AppDomain.CurrentDomain.BaseDirectory;
Console.WriteLine("================path:" + path);
//判断文件所在的文件夹是否存在,如果不存在就创建文件夹
if (Directory.Exists(path+"backUp")==false)
{
//创建文件夹
Directory.CreateDirectory(path + "backUp");
/* Directory.SetCreationTime(path + "backUp", DateTime.Now );//设置文件夹创建时间
Directory.SetLastWriteTime(path + "backUp", DateTime.Now);//设置文件夹最近被修改时间
Directory.SetLastAccessTime(path + "backUp", DateTime.Now);//设置文件夹最近被访问时间*/
FileAttributes MyAttributes = File.GetAttributes(path + "backUp");
File.SetAttributes(path + "backUp",MyAttributes|FileAttributes.Hidden); //设置文件夹隐藏
/* File.SetAttributes(path + "backUp", FileAttributes.Normal);//设置文件夹属性为正常
File.SetAttributes(path + "backUp", FileAttributes.ReadOnly);//设置成只读文件夹
File.SetAttributes(path + "backUp", MyAttributes | FileAttributes.System);//设置添加系统文件夹
File.SetAttributes(path + "backUp", MyAttributes | FileAttributes.Archive);//设置添加归档文件夹*/
}
else
{ //如果存在,判断文件是否存在
if (File.Exists(path + "backUp/backUp.txt") == false)
{
File.Create(path + "backUp/backUp.