版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wtxhai/article/details/88660136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Example605
{
class Program
{
static void Main(string[] args)
{
string strFile = "Program.cs"; //定义字符串
Console.WriteLine("文件完整名称:" + strFile); //输出文件完整名称
string strFileName = strFile.Substring(0, strFile.IndexOf('.')); //获取文件名
string strExtension = strFile.Substring(strFile.IndexOf('.')); //获取扩展名
Console.WriteLine("文件名:" + strFileName); //输出文件名
Console.WriteLine("扩展名:" + strExtension); //输出扩展名
Console.ReadLine();
}
}
}