예를 들어 프로젝트 디렉토리에서 파일 수를 얻고 싶으면. Java
에서 나는 작성합니다프로젝트 디렉토리의 경로를 얻는 방법
int numberOfFiles = new File(".").listFiles().length;
하지만 .NET에서 프로젝트의 디렉토리 경로를 얻는 방법을 모르겠어요. 어떻게 C#에서 동일한 목표를 달성하기 위해?
예를 들어 프로젝트 디렉토리에서 파일 수를 얻고 싶으면. Java
에서 나는 작성합니다프로젝트 디렉토리의 경로를 얻는 방법
int numberOfFiles = new File(".").listFiles().length;
하지만 .NET에서 프로젝트의 디렉토리 경로를 얻는 방법을 모르겠어요. 어떻게 C#에서 동일한 목표를 달성하기 위해?
가까이
var path = Path.GetDirectoryName(Application.ExecutablePath);
var files = Directory.GetFiles(path);
당신은 Application.ExecutablePath
를 사용하여 실행 파일의 경로를 가져온 다음 거기에서 디렉토리를 얻을 수 있습니다.
var executingDir = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
var numFiles = System.IO.Directory.GetFiles(executingDir).Count();
Console.WriteLine(numFiles);
가능한 중복 : http://stackoverflow.com/questions/1658518/getting-the-absolute-path-of-the-executable- 디렉터리가 있으면, 파일 수를 쉽게 얻을 using-c – Pedrom