0

Can't get access to create a file

https://code.sololearn.com/c6VYX71LF3bU/?ref=app Here is the code in windows forms

21st Oct 2019, 12:04 PM
Dead Lord
Dead Lord - avatar
11 Answers
+ 3
You don't write file name in the end of path. For example your path must be "E:\test.txt"
25th Oct 2019, 6:40 AM
id001x
id001x - avatar
+ 2
1) try start program as admin 2) try use StreamWriter instead File.Create Exceptions UnauthorizedAccessException The caller does not have the required permission. -or- path specified a file that is read-only. -or- path specified a file that is hidden.
21st Oct 2019, 2:55 PM
id001x
id001x - avatar
+ 2
I test it, and all working. Without name of file - UnauthorizedAccessException
25th Oct 2019, 9:09 AM
id001x
id001x - avatar
+ 2
And one more, you must use file.close() after operation.
25th Oct 2019, 10:42 AM
id001x
id001x - avatar
+ 1
I think, it is some trouble with OS , authorization, but tomorrow i test it. are folder in which you try create file is not system folder?
24th Oct 2019, 6:34 PM
id001x
id001x - avatar
+ 1
Dead Lord i'm glad, that's your problem are solved 🙃 P.s. thanks for marking as best answer!
28th Oct 2019, 6:56 PM
id001x
id001x - avatar
+ 1
id001x thank you for the help! Really useful
28th Oct 2019, 7:28 PM
Dead Lord
Dead Lord - avatar
0
Your program is not running properly. Please fix that and then Check.
21st Oct 2019, 2:16 PM
A͢J
A͢J - avatar
0
id001x same sh** if I use streamWriter. System.UnauthorizedAccessException
24th Oct 2019, 6:29 PM
Dead Lord
Dead Lord - avatar
0
id001x no. It's just E:/ or eve when I choose some folder from there, same prblm
24th Oct 2019, 6:38 PM
Dead Lord
Dead Lord - avatar
0
id001x is that really that simple!? :D no way!) I'll test it this evening :)
25th Oct 2019, 9:06 AM
Dead Lord
Dead Lord - avatar