当前位置:网站首页>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} 不存在!");
}
边栏推荐
- MySQL high-level statements (1)
- Connection reset by peer 问题解析
- MySQL database video tutorial from beginner to proficient
- [数据集][VOC]男女数据集voc格式6188张
- Nacos installation configuration and single-machine deployment tutorial
- CAT1 4G+以太网开发板腾讯云手机微信小程序显示温度和下发控制
- 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
- Servlet
- Difference between npm and yarn
- MySQL Index Common Interview Questions (2022 Edition)
猜你喜欢

Node installation and environment configuration

Nacos database configuration

node安装及环境变量配置

振兴农村循环经济 和数链串起农业“生态链”
![[Cartoon] 2021 full score programmer behavior comparison table (latest version)](/img/18/2679b35f39b909aa6e013ddf01114b.png)
[Cartoon] 2021 full score programmer behavior comparison table (latest version)

MySQL Advanced - MVCC (ultra-detailed finishing)

About the local server problem after ue4.27 pixel streaming package

MySQL高级语句(一)

Toolbox App 1.25 New Features at a Glance | Version Update

HCIP 第三天实验
随机推荐
npm ---- install yarn
odoo field 设置匿名函数domain
A detailed introduction to the deployment and usage of the Nacos registry
typescript ‘props‘ is declared but its value is never read 解决办法
HCIP 第三天实验
nacos源码启动找不到istio包
Node installation and configuration of environment variables
Nodejs安装教程
node安装及环境变量配置
Ue after video tutorial first
Dataset:机器学习中常用数据集下载链接集合之详细攻略
Kingdee International: Lost in half a year and last year, how does the business model of frantically burning money continue
Servlet
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
有人开源全凭“为爱发电”,有人却用开源“搞到了钱”
MySQL高级语句(一)
Mining game (C language)
MySQL经典50道练习题及全网最详细解析
GCC编译器技术解析
punch day05