我有OS XP俄语版,安装程序后显示错误“俄语中的路径无法读取” - 以我的方式解释。有人有任何想法吗?感谢
public string getDBpath() { string path1 = System.Windows.Forms.Application.StartupPath; string path2 = "safer.sdf"; string path3 = Path.Combine(path1, path2); return path3; } public string getXmlPath() { string path1 = System.Windows.Forms.Application.StartupPath; string path2 = @"data/fp.xml"; string path3 = Path.Combine(path1, path2); return path3; } public string getXmlPathTxt() { string path1 = System.Windows.Forms.Application.StartupPath; string path2 = @"data/xml_data.txt"; string path3 = Path.Combine(path1, path2); return path3; }
答案 0 :(得分:0)
不确定这是否可以解决问题,但您可以尝试将System.Windows.Forms.Application.StartupPath
更改为Assembly.GetExecutingAssembly().Location
,看看是否可以解决问题。
public string getDBpath() {
string path1 = Assembly.GetExecutingAssembly().Location;
string path2 = "safer.sdf";
string path3 = Path.Combine(path1, path2);
return path3;
}
public string getXmlPath() {
string path1 = Assembly.GetExecutingAssembly().Location;
string path2 = @"data/fp.xml";
string path3 = Path.Combine(path1, path2);
return path3;
}
public string getXmlPathTxt() {
string path1 = Assembly.GetExecutingAssembly().Location;
string path2 = @"data/xml_data.txt";
string path3 = Path.Combine(path1, path2);
return path3;
}
答案 1 :(得分:0)
您可以尝试使用Thread.GetDomain().BaseDirectory
代替System.Windows.Forms.Application.StartupPath
。
如果这不起作用,我会建议您附加到已部署的应用程序版本。因此,您可以轻松添加Debugger.Launch();
,以便创建您的广告。