Path
docs.microsoft.com/en-us/dotnet/api/system.io.path?view=net-5.0
Path Class (System.IO)
Performs operations on String instances that contain file or directory path information. These operations are performed in a cross-platform manner.
docs.microsoft.com
마지막으로 Path
System.IO
에 있는 내용들을 활용하면 파일관련사항들은 처리 할 수 있다.
using System.IO;
namespace __Path
{
class Program
{
static void Main(string[] args)
{
var path = "경로";
var dotIndex = path.IndexOf('.');
var extension = path.Substring(dotIndex);
// Get Extension
Path.GetExtension(path);
// Get Filename
Path.GetFileName(path);
// Get FileName Without Extension
Path.GetFileNameWithoutExtension(path);
// Get Directory
Path.GetDirectoryName(path);
}
}
}
'C# > Basic' 카테고리의 다른 글
TimeSpan (시간) (0) | 2021.03.12 |
---|---|
DateTime (날짜 / 시간) (0) | 2021.03.11 |
Directory, DirectoryInfo (0) | 2021.03.09 |
File, FileInfo (0) | 2021.03.08 |
제네릭 (Generic) 1 (0) | 2021.02.28 |
댓글
이 글 공유하기
다른 글
-
TimeSpan (시간)
TimeSpan (시간)
2021.03.12 -
DateTime (날짜 / 시간)
DateTime (날짜 / 시간)
2021.03.11 -
Directory, DirectoryInfo
Directory, DirectoryInfo
2021.03.09 -
File, FileInfo
File, FileInfo
2021.03.08