2011-02-03 5 views
2

응용 프로그램 디렉터리를 가져 와서 해당 경로에 파일 이름을 추가해야합니다. 그래서 나는 그것을이 방법으로 사용했다.응용 프로그램 폴더를 가져 오십시오.

String kofaxTextFilePath = Path.GetDirectoryName(Assembly.GetAssembly(typeof(File)).CodeBase) + "\\KofaxBatchHistory.txt" 

이렇게 경로가 표시됩니다.

“file:\\C:\\Documents and Settings\\MyApplication\\ KofaxBatchHistory.txt” 

하지만이 문자열에 어떤 일을하고 밖으로 만

C:\\Documents and Settings\\MyApplication\\ KofaxBatchHistory.txt 

을 얻을 필요가 직접 얻을 수있는 방법이있다?

답변

2
string myDir = System.Reflection.Assembly.GetExecutingAssembly().Location; 
myDir = System.IO.Path.GetDirectoryName(myDir); 
String kofaxTextFilePath = System.IO.Path.Combine(myDir, "KofaxBatchHistory.txt"); 
1

시도 Assembly.Location.

Assembly.GetAssembly(typeof(File)).Location 

또는 (더 좋은) :

typeof(File).Assembly.Location 
관련 문제