Reputation: 823
I have this code:
string log_file_name = @"\logger.txt";
string logger_file_to_read = Path.GetDirectoryName(Application.LocalUserAppDataPath) + @"\log";
string LoggerFile = Path.Combine(logger_file_to_read, log_file_name);
I used a breakpoint and i see that : logger_file_to_read contain:
C:\Users\bout0_000\AppData\Local\Diagnostic_Tool_Blue_Screen\Diagnostic Tool Blue Screen\log
And that log_file_name contain:
\logger.txt
But then i see that LoggerFile contain only the file name: \logger.txt Without the directory.
Whay is that ?
Upvotes: 1
Views: 618
Reputation: 41
Drop the backslash in your file name like this:
string log_file_name = "logger.txt";
Upvotes: 0
Reputation: 40838
It's right there in the documentation:
If path2 does not include a root (for example, if path2 does not start with a separator character or a drive specification), the result is a concatenation of the two paths, with an intervening separator character. If path2 includes a root, path2 is returned.
Upvotes: 7