scoped_dir 폴더 삭제 프로그램
오늘은 본업인 프로그래밍 이야기를 해볼게요
AWS에 하드용량 줄이려고 scoped_dir 정체모를 파일이 계속 늘어나서
50gb 가 넘어서 삭제하는데 너무 시간이 걸려서 간단프로그램 제작
scoped_dir 폴더 삭제시 너무 시간이 많이 걸려서 간단한 삭제 프로그램 배포합니다.
해당프로그램은 Window폴더에서 Environment.SpecialFolder.Windows 개체를 이용해서 SystemTemp 폴더를 찾습니다.
그후 scoped_dir로 시작하는 모든 디렉토리를 삭제하는 로직입니다.
아래 코드 요약
//윈도우 시스템디렉토리 SystemTemp 디렉토리 찾기 찾기
string systemTempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "SystemTemp");
//scoped_dir* 시작하는 폴더 조회
string[] scopedDirs = Directory.GetDirectories(systemTempPath, "scoped_dir*", SearchOption.TopDirectoryOnly);
foreach (string scopedDir in scopedDirs)
{
try
{
//디렉토리 삭제
Directory.Delete(scopedDir, true);
Console.WriteLine($"Deleted directory: {scopedDir}");
}
catch (Exception ex)
{
Console.WriteLine($"Error deleting directory {scopedDir}: {ex.Message}");
}
}
Console.WriteLine("Done!");
저장디스크 용량이 모자라서 용량을 확보하려면 다운받아서 실행해보세요.