Your code looks correct. Are you sure you are looking at the correct directory? This code will create the folder under the Documents of the user running the code. Verify the full path set by LogPath
is correct and then step through the code to confirm that Exists
is returning true if it doesn't exist.
c# Environment.SpecialFolder.MyDocuments creating issue
T.Zacks
3,996
Reputation points
I want to create a log folder in this location C:\Users\administrator\Documents i tried this code but below code not able to create directory in that location. program not throwing error but not able to create folder in Documents folder. i tried this code
LogPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Log";
if (!Directory.Exists(LogPath))
{
Directory.CreateDirectory(LogPath);
}
where i made the mistake for which log folder not creating in document folder?
please share the right code. thanks
Developer technologies C#
11,570 questions
1 answer
Sort by: Most helpful
-
Michael Taylor 60,161 Reputation points
2021-07-07T13:26:02.407+00:00