博客
关于我
C# 文件处理专题
阅读量:91 次
发布时间:2019-02-26

本文共 2681 字,大约阅读时间需要 8 分钟。

C#?????????????????????????????

?C#?????????????????????System.IO??????Path????????????????????????????????????????????????

1. ???????????

?????????????????Environment.CurrentDirectory???????????

string fileDir = Environment.CurrentDirectory;Console.WriteLine("???????" + fileDir);

2. ???????

????????????????Path.GetFullPath????????????????????

string filePath = "C:\\JiYF\\BenXH\\BenXHCMS.xml";string str = "?????????" + Path.GetFullPath(filePath);Console.WriteLine(str);

3. ?????????

???????????????Path.GetDirectoryName???????????

str = "??????????" + Path.GetDirectoryName(filePath);Console.WriteLine(str);

4. ?????????????

????????????????????Path.GetFileName???????????

str = "????????????" + Path.GetFileName(filePath);Console.WriteLine(str);

5. ??????????????

????????????????????????Path.GetFileNameWithoutExtension???????????

str = "????????????" + Path.GetFileNameWithoutExtension(filePath);Console.WriteLine(str);

6. ???????????

???????????????????Path.GetExtension???????????

str = "????????????" + Path.GetExtension(filePath);Console.WriteLine(str);

7. ????????

??????????????Path.GetPathRoot???????????

str = "?????????" + Path.GetPathRoot(filePath);Console.WriteLine(str);

??????

???????????

using System;using System.IO;class Program{    static void Main(string[] args)    {        // ???????????        string fileDir = Environment.CurrentDirectory;        Console.WriteLine("???????" + fileDir);        // ??????        string filePath = "C:\\JiYF\\BenXH\\BenXHCMS.xml";        Console.WriteLine("???????" + filePath);        // ????????        string str = "?????????" + Path.GetFullPath(filePath);        Console.WriteLine(str);        // ?????????        str = "??????????" + Path.GetDirectoryName(filePath);        Console.WriteLine(str);        // ?????????????        str = "????????????" + Path.GetFileName(filePath);        Console.WriteLine(str);        // ??????????????        str = "????????????" + Path.GetFileNameWithoutExtension(filePath);        Console.WriteLine(str);        // ???????????        str = "????????????" + Path.GetExtension(filePath);        Console.WriteLine(str);        // ????????        str = "?????????" + Path.GetPathRoot(filePath);        Console.WriteLine(str);        Console.ReadKey();    }}

????

????????????????

???????C:\Users\Username\Documents\JiYF\BenXH???????C:\JiYF\BenXH\BenXHCMS.xml?????????C:\JiYF\BenXH\BenXHCMS.xml??????????C:\JiYF\BenXH????????????BenXHCMS.xml????????????BenXHCMS????????????.xml?????????C:\

????

  • ????????using System;?using System.IO;????
  • ???????????Visual Studio??????????????????????????????????
  • ???????????????????Visual Studio????????IntelliSense???????

??????????????????C#????????

转载地址:http://fjnk.baihongyu.com/

你可能感兴趣的文章
Objective-C实现字符串Z 函数或 Z 算法(附完整源码)
查看>>
Objective-C实现字符串加解密(附完整源码)
查看>>
Objective-C实现字符串复制功能(附完整源码)
查看>>
Objective-C实现完整的ComplexNumber复数类(附完整源码)
查看>>
Objective-C实现将位转换为浮点数bitsToFloat算法(附完整源码)
查看>>
Objective-C实现将彩色图像转换为负片算法(附完整源码)
查看>>
Objective-C实现将给定的 utf-8 字符串编码为 base-16算法(附完整源码)
查看>>
Objective-C实现巴比伦平方根算法(附完整源码)
查看>>
Objective-C实现开方数(附完整源码)
查看>>
Objective-C实现异或密码算法(附完整源码)
查看>>
Objective-C实现循环队列算法(附完整源码)
查看>>
Objective-C实现快速排序算法(附完整源码)
查看>>
Objective-C实现打格点算法(附完整源码)
查看>>
Objective-C实现批量修改文件类型算法(附完整源码)
查看>>
Objective-C实现找出一个数的质因数primeFactors算法(附完整源码)
查看>>
Objective-C实现操作MySQL(附完整源码)
查看>>
Objective-C实现数组去重(附完整源码)
查看>>
Objective-C实现数组的循环左移(附完整源码)
查看>>
Objective-C实现数除以二divideByTwo算法(附完整源码)
查看>>
Objective-C实现文件分割(附完整源码)
查看>>