Windows Controlled Folder Access
I’d almost completed a major new Windows graphics application ‘Magic Water Mark’ when I hit a typical Microsoft road-block. My tried and tested routines for saving Image Files all failed to work – creating a System.Exception: “A generic error occurred in GDI+.”. Absolutely no helpful debug information available anywhere.
The problem appeared for an application using Visual Studio 2022 with .Net 8.0
Yet earlier Applications using Visual Studio 2019 with .Net Framework 4.8 still seemed to work fine!
Sods law make it almost impossible to change my latest project back to one able to use Visual Studio 2019 – so I wasted hours looking for solutions in the wrong place.
Google searches about GDI+ errors only produced suggestions for beginners trying to save images.
Hours of frustration were eventually rewarded when I slowly understood the error had nothing to do with GDI+ but instead a single manifested problem caused by Microsofts introduction of “Controlled Folder Access”.
“Controlled Folder Access” was created by Microsoft to prevent unwanted access to a PC’s data files – Documents, Downloads, Music and Pictures.
It can easily be turned On and Off by an administrator from Windows security.
With Controlled Folder Access turned on, only Microsoft Approved applications can write to files within Documents, Downloads, Music and Pictures folders – unless the application has been individually selected to allow it access to these folders.
Later searches into problems associated with Controlled Folder Access suggests it may cause all sorts of unexpected problems with legacy Windows software. There is absolutely no meaningful warning of what is going wrong!
Controlled Folder Access almost certainly eliminates the problem of RansomWare attacks – so I am happy to keep mine turned on.
But I’ve also been going through the older PC applications I use all the time and adding them to the list of Trusted Applications in Windows Security. This prevents them from being blocked by Controlled Folder Access and ensures they don’t end up behaving in weird or unexpected ways or maybe creating errors that I don’t even even notice.