简体   繁体   中英

C# current application Path and file name

I want to open file with current application localization and file name. I have done something like this: private string appPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath); and than I try to do appPath + "filename" , but I got an exeption with no file found. When I manually write localization of file it is found and it can be open. Could you help me?

Try this: Path.Combine(appPath, "filename"); .

Most likely it's a missing backslash (or whatever the path separator char is on your system) between the appPath and the file name. The Combine method will take care of that for you.

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