首页 > Windows开发 > 详细

c# Path

时间:2020-10-16 11:11:45      阅读:37      评论:0      收藏:0      [点我收藏+]

 

 

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _02Path的使用方法
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = @"E:\dotNet\Study\文件操作学习New.txt"; 

            //获取文件名;
            string fileName = Path.GetFileName(str);
            Console.WriteLine(fileName);

            //获取文件目录;
            string dirName = Path.GetDirectoryName(str);
            Console.WriteLine(dirName);

            //获取文件目录完整路径;
            string dirPath = Path.GetFullPath(str);
            Console.WriteLine(dirPath);

            //获取文件扩展名;
            string fileExt = Path.GetExtension(str);
            Console.WriteLine(fileExt);

            //获取文件名不带扩展名;
            string fileName1 = Path.GetFileNameWithoutExtension(str);
            Console.WriteLine(fileName1);

            Console.ReadKey();
            
        }
    }
}

 

c# Path

原文:https://www.cnblogs.com/nymz/p/13824915.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!