博客
关于我
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实现binomial distribution二项分布算法(附完整源码)
查看>>
Objective-C实现bisection二分法算法(附完整源码)
查看>>
Objective-C实现bisection二等分算法(附完整源码)
查看>>
Objective-C实现BitMap算法(附完整源码)
查看>>
Objective-C实现bitmask位掩码算法(附完整源码)
查看>>
Objective-C实现bitonic sort双调排序算法(附完整源码)
查看>>
Objective-C实现BloomFilter布隆过滤器的算法(附完整源码)
查看>>
Objective-C实现BMP图像旋转180度(附完整源码)
查看>>
Objective-C实现bogo sort排序算法(附完整源码)
查看>>
Objective-C实现boruvka博鲁夫卡算法(附完整源码)
查看>>
Objective-C实现Boyer-Moore字符串搜索算法(附完整源码)
查看>>
Objective-C实现BP误差逆传播算法(附完整源码)
查看>>
Objective-C实现breadth First Search广度优先搜索算法(附完整源码))
查看>>
Objective-C实现BreadthFirstSearch广度优先搜索算法(附完整源码)
查看>>
Objective-C实现BreadthFirstShortestPath广度优先最短路径算法(附完整源码)
查看>>
Objective-C实现bubble sort冒泡排序算法(附完整源码)
查看>>
Objective-C实现bucket sort桶排序算法(附完整源码)
查看>>
Objective-C实现Burke 抖动算法(附完整源码)
查看>>
Objective-C实现Burrows-Wheeler 算法(附完整源码)
查看>>
Objective-C实现CaesarsCiphe凯撒密码算法(附完整源码)
查看>>