-
Jun 10th, 2021, 06:33 AM
#1
Thread Starter
Member
[RESOLVED] Odd write permissions issue
I have just had an odd issue with write permissions that has only just started affecting all of my projects (well, i've tried around 5 and all the same) I test whether the user has write permissions on the app folder using the below in a Try...Catch which had always worked fine:
Code:
IO.File.WriteAllText(fPath, "Test write permissions.")
However since the day before yesterday the test fails! I have checked over and over that fPath is correct (even copy-pasting the debug value into explorer! I can manually create a text file in the dir, so no issues there. If i comment out the test lines and run it then it is fine, even writing the .ini files correctly, so no issues there. So what could have changed to make this test fail? I'm really confused!
-
Jun 10th, 2021, 06:48 AM
#2
Thread Starter
Member
Re: Odd write permissions issue
Update: By way of test I just changed the fPath to a hard-coded path (e.g. "C:\mydir\textfile.txt") and it still failed. I then changed it to the same but without the extension .txt and it worked fine.
Another clue is that i uninstalled Microsoft Office completely the other day and now have open office on my machine...
-
Jun 10th, 2021, 07:05 AM
#3
Re: Odd write permissions issue
What's the error message when it fails?
-
Jun 10th, 2021, 07:10 AM
#4
Thread Starter
Member
Re: Odd write permissions issue
Apologies. It's "Access to the path 'path' is denied."
-
Jun 10th, 2021, 07:54 AM
#5
Thread Starter
Member
Re: Odd write permissions issue
Update2: If i change it to any 'known' extension (.jpg, .mp3, .txt, .pdf whatever) it fails. Use any not known extension (.zzz) and it works fine.
-
Jun 10th, 2021, 08:00 AM
#6
Re: Odd write permissions issue
Yeah, that is odd. No idea what's going on there.
-
Jun 10th, 2021, 08:07 AM
#7
Thread Starter
Member
Re: Odd write permissions issue
Originally Posted by jmcilhinney
Yeah, that is odd. No idea what's going on there.
Nah! I'm not having that you don't know, John!
The problem is it's affecting every project i have and as is i can't do any modifications or recompile (well, theoretically i can if i use no extension) I have even uninstalled OpenOffice now as that's the only thing, other than a VS update that has changed on my system.
-
Jun 10th, 2021, 08:15 AM
#8
Hyperactive Member
Re: Odd write permissions issue
Have you tried other paths, like desktop, documents, etc?
EDIT
Just saw where you said you had
What about restarting your computer? There may be a pending windows update that hasn’t fully went through screwing things up.
-
Jun 10th, 2021, 08:21 AM
#9
Thread Starter
Member
Re: Odd write permissions issue
Yeah, computer had been rebooted many times. The next one will be from a great height.
-
Jun 10th, 2021, 08:26 AM
#10
Hyperactive Member
Re: Odd write permissions issue
How about any previous builds of the project? Can you go to a local back up or a previous published version to see if it has the same effect?
-
Jun 10th, 2021, 08:31 AM
#11
Thread Starter
Member
Re: Odd write permissions issue
Originally Posted by Frabulator
How about any previous builds of the project? Can you go to a local back up or a previous published version to see if it has the same effect?
I have all my projects on GIT so tried that, exactly the same result.
Update again: I have just run an app i wrote from it's .exe (i.e. completely outside of VS) I tried this app because it produces a log file with extension .txt It runs with no issue at all. So the issue seems something inside VS?
-
Jun 10th, 2021, 08:34 AM
#12
Hyperactive Member
Re: Odd write permissions issue
Try to make a brand new project and open a file. It might be that your project is messed up. If the same thing happens then it’s got to be VS.
-
Jun 10th, 2021, 08:39 AM
#13
Thread Starter
Member
Re: Odd write permissions issue
Originally Posted by Frabulator
Try to make a brand new project and open a file. It might be that your project is messed up. If the same thing happens then it’s got to be VS.
But it's every project - i've tried multiple.
Another update: It seems to be only C drive. It works pointing to d:, x:, and z:
(BTW: i do appreciate all your thoughts)
-
Jun 10th, 2021, 08:43 AM
#14
Hyperactive Member
Re: Odd write permissions issue
I wonder if VS is being caught by a virus scan and not allowing access to files? That could explain only being able to access unknown file types and only being restricted to the main OS drive
-
Jun 10th, 2021, 08:53 AM
#15
Thread Starter
Member
Re: Odd write permissions issue
Originally Posted by Frabulator
I wonder if VS is being caught by a virus scan and not allowing access to files? That could explain only being able to access unknown file types and only being restricted to the main OS drive
Great shout. I just disabled my virus software (Avast free) and it works. Looks like your persistence got there Frabulator.
Now two questions:
1. Why didn't i try that earlier (will get someone to kick me in the nuts later)
2. What do i change on Avast to allow VS permissions?
-
Jun 10th, 2021, 08:58 AM
#16
Hyperactive Member
Re: Odd write permissions issue
I havent used avast in a few years, but from what I remember you need to whitelist the program. I think you have to go into the restrictions and set visual studios as a trusted application. Again, I might be completely wrong, it has been a while.
Glad I could help!
-
Jun 10th, 2021, 09:05 AM
#17
Thread Starter
Member
Re: Odd write permissions issue
Definitely in the right direction but still something not right:
Avast disabled: Tests good via VS and running an .exe independent of VS
Avast enabled: Tests fail via VS but also fails when running an .exe independent of VS
So VS now not the issue? Avast is.
Edit: Disable only the Ransomware Shield and it works.
Last edited by DavyEFC; Jun 10th, 2021 at 09:19 AM.
-
Jun 10th, 2021, 09:31 AM
#18
Thread Starter
Member
Re: Odd write permissions issue
Ok so the issue is now resolved. Solution was simply to add an exception to the VS projects directory. Question that will probably never be answered is why did i have to add that exception now; what had changed? The only change i made was to uninstall MSOffice. Ah well.
Thanks to those for their thoughts, particularly @Frabulator.
-
Jun 10th, 2021, 10:15 AM
#19
Re: [RESOLVED] Odd write permissions issue
Well, with several high profile RansomWare attacks dominating IT Security news now for several weeks, it wouldn't surprise me if AV companies are making changes to their definitions/scanning that make them really aggressive trying to prevent such attacks, with the not unexpected result of there will likely be many false positives. Basically, they've probably decided (or been "encouraged" to decide by the US government and agencies) that preventing RansomWare at the risk of breaking legit things is better (right now anyway) than making sure legit things work at the risk of letting RansomWare run.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|