After publishing application error occurs in finding path to database and xml files
I have OS XP Russian version, after installing programm shows errors "path in russian can not be read" - explaining in my way. Does anybody have any idea? Thanks
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; 开发者_Python百科string path2 = @"data/xml_data.txt"; string path3 = Path.Combine(path1, path2); return path3; }
Not sure if this would solve the problem but you could try changing the System.Windows.Forms.Application.StartupPath
to Assembly.GetExecutingAssembly().Location
, and see if that fixes it.
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;
}
You can try to use Thread.GetDomain().BaseDirectory
instead of System.Windows.Forms.Application.StartupPath
.
If this is not working I would advice you to attach to the deployed version of your application. Therefor you can easily add Debugger.Launch();
right befor your pathes are created.
精彩评论