| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
Tags
- STS
- SCADA
- Linux
- Eclipse
- LOG
- Custom
- 리눅스
- 말라키
- 맥코트
- ORA-28002
- DataTables
- pythoncom37.dll
- checkbox
- JQuery
- Python
- build
- error
- 원한
- 명령어
- 파이썬
- Anaconda
- HMI
- geckodriver
- 가상환경
- 분노
Archives
- Today
- Total
2010년 5월 1일, 2막
[C#] 파일명과 확장자 추출 예제 본문
public class 파일명추출
{
//전체 경로가 입력되었을 때 파일명과 확장자 추출
public static void Main(string[] args)
{
string dir = "c:\\Website\\redPlus\\Images\\test.gif";
string fullName = String.Empty;
string name = "";
string ext = name;
//전체 파일명 : test.gif
fullName = dir.Substring(dir.LastIndexOf('\\') + 1);
//순수 파일명 : test
name = fullName.Substring(0, fullName.LastIndexOf('.'));
//확장자 : gif
ext = fullName.Substring(fullName.LastIndexOf('.'));
Console.WriteLine(fullName);
Console.WriteLine((name));
Console.WriteLine(ext);
}
}
'Computer' 카테고리의 다른 글
| [C#] mdb handling (0) | 2013.04.13 |
|---|---|
| [C#] 로그인 처리 하기 (0) | 2013.04.09 |
| [C#] OpenFileDialog에서 경로 가지고 오기 (0) | 2013.04.03 |
| [C#] 상속받은 Form의 버튼을 수정하고자 할 때 (0) | 2013.04.02 |
| [DevExpress] How to remove "Drag a column header here to group by that column" (0) | 2013.04.02 |