博客
关于我
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/

你可能感兴趣的文章
Plotly-Dash:如何过滤具有多个数据框列的仪表板?
查看>>
Plotly:如何为 x 轴上的时间序列设置主要刻度线/网格线的值?
查看>>
Plotly:如何从 x 轴删除空日期?
查看>>
Plotly:如何从单条迹线制作堆积条形图?
查看>>
Plotly:如何以 Root 样式绘制直方图,仅显示直方图的轮廓?
查看>>
Plotly:如何使用 Plotly Express 组合散点图和线图?
查看>>
Plotly:如何使用 plotly.graph_objects 和 plotly.express 定义图形中的颜色?
查看>>
Plotly:如何使用 Python 对绘图对象条形图进行颜色编码?
查看>>
Plotly:如何使用 updatemenus 更新一个特定的跟踪?
查看>>
Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?
查看>>
Plotly:如何向烛台图添加交易量
查看>>
Plotly:如何在 plotly express 中找到趋势线的系数?
查看>>
Plotly:如何在桑基图中设置节点位置?
查看>>
Plotly:如何处理重叠的颜色条和图例?
查看>>
Plotly:如何手动设置 plotly express 散点图中点的颜色?
查看>>
Plotly:如何结合 make_subplots() 和 ff.create_distplot()?
查看>>
Plotly:如何绘制累积的“步骤“;直方图?
查看>>
PLSQL developer12安装图解
查看>>
PLSQL window操作
查看>>
plsql 存储过程 测试
查看>>