c# 获取文件最后修改日期代码
FileInfo f = new FileInfo(@"c:\1.txt");
Console.WriteLine(f.LastWriteTime.ToString());
c# 获取文件最后访问时间代码
FileInfo f = new FileInfo(@"c:\1.txt");
Console.WriteLine(f.LastAccessTime.ToString());//最后访问
c# 获取文件创建时间代码
FileInfo f = new FileInfo(@"c:\1.txt");
Console.WriteLine(f.CreationTime.ToString());
c# 获取文件大小代码
FileInfo f = new FileInfo(@"c:\1.txt");
Console.WriteLine(f.Length.ToString());
c# 获取文件文件属性代码
FileInfo f = new FileInfo(@"c:\1.txt");
Console.WriteLine(f.Attributes);
C#文件路径
FileInfo f = new FileInfo(@"c:\1.txt");
Console.WriteLine(f.DirectoryName);
C#追加文件
StreamWriter sw = File.AppendText(Server.MapPath(".")+"\\myText.txt");
sw.WriteLine("追逐理想");
sw.WriteLine("kzlll");
sw.WriteLine(".NET笔记");
sw.Flush();
sw.Close();
C#拷贝文件
string OrignFile,NewFile;
OrignFile = Server.MapPath(".")+"\\myText.txt";
NewFile = Server.MapPath(".")+"\\myTextCopy.txt";
File.Copy(OrignFile,NewFile,true);
C#删除文件
string delFile = Server.MapPath(".")+"\\myTextCopy.txt";
File.Delete(delFile);
C#移动文件
string OrignFile,NewFile;
OrignFile = Server.MapPath(".")+"\\myText.txt";
NewFile = Server.MapPath(".")+"\\myTextCopy.txt";
File.Move(OrignFile,NewFile);
讲文件从一个目录复制到另一个目录
FileInfo fi = new FileInfo(path1);
fi.CopyTo(path2, true);
path1源文件路径,path2目标文件路径。