当前位置:网站首页>分解路径为目录名和文件名的方法
分解路径为目录名和文件名的方法
2022-07-28 05:29:00 【angleoldhen】
using System;
class Test
{
static void SplitPath(string path,out string dir,out string name)
{
int i = path.Length;
while (i > 0)
{
char ch = path[i-1];
if (ch == '\\' || ch == '/' || ch == ':')
break;
i--;
}
dir = path.Substring(0,i);
name = path.Substring(i);
}
static void Main()
{
string dir, name;
SplitPath("c:\\windows\\system\\hello.txt",out dir,out name);
Console.WriteLine("目录名:{0}",dir);
Console.WriteLine("文件名:{0}",name);
}
}
边栏推荐
- Es6--- > arrow function, class, modularization
- Test interview questions collection (III) | computer network and database (with answers)
- MOOC翁恺C语言第七周:数组运算:1.数组运算2.搜索3.排序初步
- Svg understanding and drawing application
- Small turtle C (Chapter 6 arrays 1 and 2)
- MySQL installation and use
- Custom components -- styles
- 远程访问云服务器上Neo4j等服务的本地网址
- MOOC翁恺C语言 第六周:数组与函数:1.数组2.函数的定义与使用3.函数的参数和变量4.二维数组
- RAID disk array
猜你喜欢

SSH service configuration

Custom components -- styles

1、 PXE overview and installation

Principle and configuration of NAT and pat

DOM -- event chain, event bubble and capture, event proxy

Applet custom components - data, methods, and properties

About gcc:multiple definition of

MOOC翁恺C语言 第六周:数组与函数:1.数组2.函数的定义与使用3.函数的参数和变量4.二维数组

Custom components -- slots

Blue Bridge Cup square filling number
随机推荐
RAID磁盘阵列
Servlet
360 compatibility issues
SSH服务配置
DHCP服务
Small turtle C (Chapter 5 loop control structure program 567) break and continue statements
组管理和权限管理
DNS域名解析
shell脚本——正则表达式
Common models in software development
Technology sharing | how to do Assertion Verification in interface automated testing?
Custom components -- styles
Applet navigator cannot jump (debug)
MOOC Weng Kai C language week 6: arrays and functions: 1. Arrays 2. Definition and use of functions 3. Parameters and variables of functions 4. Two dimensional arrays
Si Han talks about the professional development of testers
Asynchronous programming promise
Operation document tree
Shell script -- program conditional statements (conditional tests, if statements, case branch statements, echo usage, for loops, while loops)
Principle and configuration of NAT and pat
[learning records of erudite Valley] Super summary, attentive sharing | collection