유럽 전역에서 사용하기 위해 현지화 된 응용 프로그램을 보유하고 있습니다.StreamReader가 파일이 존재하지 않는다고 불평하지만
디스크에서 파일을로드하는 메뉴 옵션이 있습니다.
이 작업은 내 dev에 컴퓨터에서 잘 작동하지만 난에서는 StreamReader 파일을 열려고하면 _, 스페인어 등
FileNotFoundException이 생성됩니다 예를 들어 프랑스어를 다른 운영 체제를 테스트하는 데 사용하는 가상 머신에서 작동하지 않습니다 .
는 " '파일 C 찾을 수 없습니다 : \ 프로그램 파일 \ MyCompany \ MyTool \ 빈 \ 파일 \ debug.txt'"라고
것입니다을, 파일이 올바른 위치와 함께, 존재 올바른 파일 이름.
대상 (프랑스어) 운영 체제의 디렉토리 이름은 dev 시스템과 동일합니다.
아이디어가 있으십니까?
string ourPath = System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
try
{
System.IO.StreamReader sr = System.IO.File.OpenText(ourPath + @"\bin\Files\debug.txt");
string input = null;
while ((input = sr.ReadLine()) != null)
{
m_text.Append(input);
}
sr.Close();
}
catch (System.IO.FileNotFoundException)
{
MessageBox.Show("LoadDebugOptions: File Not Found: " + ex.Message);
}
File.Exists 메서드를 사용하여 파일이 존재하는지 확인해보십시오. – Faisal