我有一个面向欧洲使用的本地化应用程序。
我有一个菜单选项,可以从磁盘加载文件。
这个操作在我的开发机上正常工作,但在我用来测试其他操作系统(如法语、西班牙语等)的虚拟机上却无法工作。
当StreamReader尝试打开文件时,会生成FileNotFoundException。
它说“'Could not find the file C:\Program Files\MyCompany\MyTool\bin\Files\debug.txt'”
问题是,文件确实存在,位于正确的位置,并且具有正确的文件名。
目标(法语)操作系统上的目录名称与开发机器上的相同。
有什么想法吗?
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);
}