当前位置:网站首页>C# FileInfo class
C# FileInfo class
2022-08-02 07:18:00 【flysh05】
FileInfo Several basic methods of the class:
1. 创建文件
FileInfo fInfo = new FileInfo("Sample.txt");
if (!fInfo.Exists)
{
fInfo.Create();
}
2. 复制文件
FileInfo fInfo = new FileInfo("Sample.txt");
//目标文件存在则覆盖
fInfo.CopyTo("SampleCopy.txt", true);
3. 移动文件,重名文件
FileInfo fInfo = new FileInfo("Sample.txt");
fInfo.MoveTo("MoveSample.txt");//重命名
4. 删除文件
FileInfo fInfo = new FileInfo("Sample.txt");
fInfo.Delete();
- 获取文件名称,文件全路径,文件路径,文件大小,read-only property
//使用绝对路径
//C:\Users\Desktop\文件操作\FileAndFolder\bin\Debug\TestFile.txt
//使用相对路径
FileInfo fInfo = new FileInfo("TestFile.txt");
//判断文件是否存在 Exists属性
if (fInfo.Exists)
{
ShowMsg($"{
fInfo.FullName} 存在!");
ShowMsg($"文件名:{
fInfo.Name}");
ShowMsg($"文件路径:{
fInfo.Directory}");
ShowMsg($"文件大小:{
fInfo.Length} byte");
ShowMsg($"文件是否只读:{
fInfo.IsReadOnly}");
}
else
{
ShowMsg($"{
fInfo.FullName} 不存在!");
}
边栏推荐
- APT + Transform to realize multi module Application distributed Application life cycle
- punch day05
- Toolbox App 1.25 新功能一览 | 版本更新
- node安装及环境配置
- postgres 多个变量填充字符串,字串格式化
- MySql 5.7.38 download and installation tutorial, and realize the operation of MySql in Navicat
- node安装和配置(node-v12.20.2-x64 ) 以及node版本切换介绍
- C# FileInfo类
- MySQL Advanced - MVCC (ultra-detailed finishing)
- npm 和 yarn的区别
猜你喜欢

node安装和配置(node-v12.20.2-x64 ) 以及node版本切换介绍

MySQL driver jar package download -- nanny tutorial

蚂蚁三面:MQ 消息丢失、重复、积压问题,有哪些解决方案?

GCC编译器技术解析

(笔记整理未完成)【图论】图的遍历

Node installation and configuration of environment variables

关于ue4.27像素流送打包后的本地服务器问题

MySQL 23 classic interviews hang the interviewer

MySQL Index Common Interview Questions (2022 Edition)

npm does not recognize the "npm" item as the name of a cmdlet, function, script file, or runnable program.Please check the spelling of the name, and if the path is included, make sure the path is corr
随机推荐
使用jOOQ 3.14合成外键在视图上写隐式连接
有点奇怪!访问目的网址,主机能容器却不行
APT + Transform 实现多模块应用Application生命周期分发
Node installation and environment configuration
Xgboost报错ValueError:无效的形状:标签(1650 2)
Specified URL is not reachable,caused by :‘Read timed out
Node installation and configuration (node-v12.20.2-x64 ) and introduction to node version switching
chrome plugin development guide
MySQL高级学习笔记
Ue after video tutorial first
leetcode solves the linked list merge problem in one step
npm、cnpm的安装
The international top conference OSDI included Taobao system papers for the first time, and the device-cloud collaborative intelligence was recommended by the keynote speech of the conference
Connection reset by peer 问题解析
typescript ‘props‘ is declared but its value is never read 解决办法
MySQL索引常见面试题(2022版)
mysql索引失效的常见9种原因详解
node安装和配置(node-v12.20.2-x64 ) 以及node版本切换介绍
排雷小游戏(C语言)
BGP+MPLS Comprehensive Experiment