0
Using directory class gives a exception in the playground
I try to write some code to play around with the directory class. When I run this code I get an exception. Unhandled Exception: System.UnauthorizedAccessException: Access to the path '..\Playground\' is denied. In this line I set the path to c:\temp string MyPath = @"c:\Temp"; Why is the playground still looking in it local directory ? https://code.sololearn.com/cf9IzYD9Da6f
4 Answers
+ 1
you asume that the playhground has a directory c:\temp\. Why? If you use
string MyPath = Path.GetTempPath();
your program works without any exception
https://code.sololearn.com/cpo9swHlzS9l/?ref=app
+ 1
it is not possible to use your own computer this way. Temp-directory is on the machine the program is running on - that means here the machine of the playground.
If your own computer is reachable from the internet you can give a public URL were write access is possible, but I wouldn't recommend that access.
0
Thank you. It does work without a exception although I am not certain it is gonna work at al.
When I run my code, the path I am getting is
..\Playground\\
the path: ..\Playground\\ does exist
This was not the path I was looking for.
I hoped to get a temporary path on my own computer.
This is probably not going to happen because of the way the playground is set up.
0
Thank you.
During this experiment, I realised I needed to think different about the playground. I was not aware that is it a remote computer.
Gone a use my own computer to experiment with directory folder access and gone a use the palyground for other coding things.