美文网首页
C#一些关于文件的基本操作

C#一些关于文件的基本操作

作者: 灬焰 | 来源:发表于2018-10-10 10:42 被阅读0次

要引入using System.IO;

1,判断文件是否存在,如果存在删除

if (File.Exists(Path.GetFullPath(positonPath)))

                {

                    File.Delete(Path.GetFullPath(positonPath));

                }

2 .给文件重命名

               FileInfo fileInfo = new FileInfo(fullpath);

                string newFileName = “123abc”;

                fileInfo.MoveTo(Path.Combine(fileInfo.DirectoryName, newFileName));

相关文章

网友评论

      本文标题:C#一些关于文件的基本操作

      本文链接:https://www.haomeiwen.com/subject/sjnygxtx.html