简体   繁体   中英

Console application tries to find database in path of local machine

I created a console application in C# which works fine in my machine. But when it is installed in other machine, it fails with error message stating that the database file is not present. Also, it tries to find the database in the path of local machine where development was done. How can I resolve this?

Looks like you've hardcoded the path for the database file in the program. You could try putting both of them in the same directory and then declaring a variable:

var path = Path.Combine(Directory.GetCurrentDirectory(), "\\fileName.txt");

and then reference that variable as the path for the database file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM