Home > Net >  Relative paths cannot access problems
Relative paths cannot access problems

Time:01-09

C # Winform
Relative path string OpenFilePath @ "Desktop \ 1. TXT"; can't access the file
The absolute path string OpenFilePath @ "C: \ Users \ \ Administrator \ Desktop \ 1. TXT". to be able to access to

And another in the same program after using the relative path can visit
What reason is this

CodePudding user response:

Your program on the desktop? Winform access path to the file
 
String OpenFilePath=AppDomain. CurrentDomain. BaseDirectory + @ "Desktop \ 1. TXT";

So can certainly, relative path is the work path, the relative path to find things, the work path has changed? When other program calls us to write the exe or DLL, work path becomes other programs work path, relative path is different, so naturally I couldn't find it
  • Related