반응형
특정 폴더내에서 xlsx 확장자를 가진 파일 모두 찾기
using System;
using System.IO;
class Program
{
static void Main()
{
// 검색할 폴더 경로를 지정
string folderPath = @"C:\your\folder\path";
// Directory.GetFiles 메소드를 사용하여 .xlsx 파일을 검색
// 이 메소드는 지정된 경로에서 특정 패턴에 맞는 파일 이름을 모두 반환
string[] xlsxFiles = Directory.GetFiles(folderPath, "*.xlsx");
// 찾은 파일들을 출력
foreach (var file in xlsxFiles)
{
// 파일의 전체 경로 출력
Console.WriteLine(file);
// 파일의 전체 경로가 아닌 파일 이름만 출력하려면 Path.GetFileName 메소드를 사용
Console.WriteLine(Path.GetFileName(file));
}
}
}
반응형
'C#' 카테고리의 다른 글
C# 솔루션, 프로젝트 빌드 경로 변경 (0) | 2024.02.08 |
---|---|
C# 윈폼(Windows Forms) 웹(Blazor + Ant Design) 메뉴 예쁘게 만들기 (0) | 2024.02.08 |
C# 엑셀 파일 불러오기(xls, xlsx) (0) | 2024.01.09 |
C# 초기화 파일 생성 및 불러오기(json) (0) | 2024.01.08 |
C# 간편한 로그 라이브러리(Serilog) (0) | 2024.01.07 |