Problems with File
-
I am trying to create a file on a directory where I have total power. The File.Create (..) (as well as any other attempt to create the file even using FileStream()) always fails with the UnauthorizedException . This is not possible since I have permission to write and create files on that directory (after all I can easily create a file by hand there). Is there an explaination ?
-
I am trying to create a file on a directory where I have total power. The File.Create (..) (as well as any other attempt to create the file even using FileStream()) always fails with the UnauthorizedException . This is not possible since I have permission to write and create files on that directory (after all I can easily create a file by hand there). Is there an explaination ?
tiwal wrote:
This is not possible since I have permission to write and create files on that directory (after all I can easily create a file by hand there).
Lousy way to test. Does your code run under YOUR credentials? What path and filename are you trying to write to?
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]
-
I am trying to create a file on a directory where I have total power. The File.Create (..) (as well as any other attempt to create the file even using FileStream()) always fails with the UnauthorizedException . This is not possible since I have permission to write and create files on that directory (after all I can easily create a file by hand there). Is there an explaination ?
Depends on what user the application is running under, rather than what access you have. If this is winforms, then I would expect it to run under your user, but a service won't, for example. Double check the folder address, and check the user ID it runs under - if it is complaining, then it is doing so for a reason!
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
-
tiwal wrote:
This is not possible since I have permission to write and create files on that directory (after all I can easily create a file by hand there).
Lousy way to test. Does your code run under YOUR credentials? What path and filename are you trying to write to?
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]
I am running a debug instance of my program. VS runs under my credentials. The path is simply the debug folder of the application. This is the same path where I was successfully reading and writing, yesterday, using the same VS, and NO change has been made since .
-
Depends on what user the application is running under, rather than what access you have. If this is winforms, then I would expect it to run under your user, but a service won't, for example. Double check the folder address, and check the user ID it runs under - if it is complaining, then it is doing so for a reason!
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
-
I am running a debug instance of my program. VS runs under my credentials. The path is simply the debug folder of the application. This is the same path where I was successfully reading and writing, yesterday, using the same VS, and NO change has been made since .
tiwal wrote:
This is the same path where I was successfully reading and writing, yesterday, using the same VS, and NO change has been made since
If the universe did not change it would behave the same. Something changed. Are you running a copy off the application outside the debugger? Viewing the file using a viewer that could "lock" the file?
tiwal wrote:
VS runs under my credentials.
There's no "run as admin"-shield on the taskbar-icon?
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]
-
I am not sure I am understanding well. Tou mean , checking the folder I am trying to write to ?
Check the name, yes - make sure that the folder you are trying to write to is exactly the folder you think it is.
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
-
tiwal wrote:
This is the same path where I was successfully reading and writing, yesterday, using the same VS, and NO change has been made since
If the universe did not change it would behave the same. Something changed. Are you running a copy off the application outside the debugger? Viewing the file using a viewer that could "lock" the file?
tiwal wrote:
VS runs under my credentials.
There's no "run as admin"-shield on the taskbar-icon?
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]
Something has changed for sure . But if I were the one who changed that something I wouldn't be here to pose this question. I am not running anything which may lock the file. After all the file cannot even be created. Running the environment as administrator even worsened things, as now the path of the file changed to something "like" root ("C:.\filename", which doen not even elaborate to a regular path).
-
Something has changed for sure . But if I were the one who changed that something I wouldn't be here to pose this question. I am not running anything which may lock the file. After all the file cannot even be created. Running the environment as administrator even worsened things, as now the path of the file changed to something "like" root ("C:.\filename", which doen not even elaborate to a regular path).
tiwal wrote:
as now the path of the file changed to something "like" root ("C:.\filename", which doen not even elaborate to a regular path).
I would suggest you have a bug in your code which is leading to an invalid path somewhere. Use your debugger to step throught the code and see the exact values of the variables that are used to create the path.
One of these days I'm going to think of a really clever signature.