Results 1 to 19 of 19

Thread: [RESOLVED] Odd write permissions issue

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2019
    Posts
    55

    Resolved [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!

  2. #2

    Thread Starter
    Member
    Join Date
    Feb 2019
    Posts
    55

    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...

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,296

    Re: Odd write permissions issue

    What's the error message when it fails?

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2019
    Posts
    55

    Re: Odd write permissions issue

    Apologies. It's "Access to the path 'path' is denied."

  5. #5

    Thread Starter
    Member
    Join Date
    Feb 2019
    Posts
    55

    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.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,296

    Re: Odd write permissions issue

    Yeah, that is odd. No idea what's going on there.

  7. #7

    Thread Starter
    Member
    Join Date
    Feb 2019
    Posts
    55

    Re: Odd write permissions issue

    Quote Originally Posted by jmcilhinney View Post
    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.

  8. #8
    Hyperactive Member Frabulator's Avatar
    Join Date
    Jan 2015
    Location
    USA
    Posts
    393

    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.
    Oops, There it goes. Yep... my brain stopped...
    _________________________________

    Useful Things:

    How to link your VB.Net application to Excel

  9. #9

    Thread Starter
    Member
    Join Date
    Feb 2019
    Posts
    55

    Re: Odd write permissions issue

    Yeah, computer had been rebooted many times. The next one will be from a great height.

  10. #10
    Hyperactive Member Frabulator's Avatar
    Join Date
    Jan 2015
    Location
    USA
    Posts
    393

    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?
    Oops, There it goes. Yep... my brain stopped...
    _________________________________

    Useful Things:

    How to link your VB.Net application to Excel

  11. #11

    Thread Starter
    Member
    Join Date
    Feb 2019
    Posts
    55

    Re: Odd write permissions issue

    Quote Originally Posted by Frabulator View Post
    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?

  12. #12
    Hyperactive Member Frabulator's Avatar
    Join Date
    Jan 2015
    Location
    USA
    Posts
    393

    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.
    Oops, There it goes. Yep... my brain stopped...
    _________________________________

    Useful Things:

    How to link your VB.Net application to Excel

  13. #13

    Thread Starter
    Member
    Join Date
    Feb 2019
    Posts
    55

    Re: Odd write permissions issue

    Quote Originally Posted by Frabulator View Post
    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)

  14. #14
    Hyperactive Member Frabulator's Avatar
    Join Date
    Jan 2015
    Location
    USA
    Posts
    393

    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
    Oops, There it goes. Yep... my brain stopped...
    _________________________________

    Useful Things:

    How to link your VB.Net application to Excel

  15. #15

    Thread Starter
    Member
    Join Date
    Feb 2019
    Posts
    55

    Re: Odd write permissions issue

    Quote Originally Posted by Frabulator View Post
    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?

  16. #16
    Hyperactive Member Frabulator's Avatar
    Join Date
    Jan 2015
    Location
    USA
    Posts
    393

    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!
    Oops, There it goes. Yep... my brain stopped...
    _________________________________

    Useful Things:

    How to link your VB.Net application to Excel

  17. #17

    Thread Starter
    Member
    Join Date
    Feb 2019
    Posts
    55

    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.

  18. #18

    Thread Starter
    Member
    Join Date
    Feb 2019
    Posts
    55

    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.

  19. #19
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,116

    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
  •  



Click Here to Expand Forum to Full Width