I am not sure if Windows Defender will try to prevent folder creation in the Documents/Downloads folder;
it should require elevated access or protection when working in Program Files or other sensitive folders.
One thing I would like you to think about is, if Windows Defender can prevent you from creating the folder, it will do the same for your users' machines. Are you okay with your process being halted for this, and do you think your users will do the same;
create or allow for a directory themselves?
Quote:
C:\Users\Sasch\OneDrive\Dokumente
<-- the OneDrive part here
Lastly, you are creating the folder not in the machine's Documents folder, but in OneDrive. I think you should see why your PC is creating the directory on OneDrive, as that is why Windows Defender or other programs are denying access. It might be because allowing such an operation will cost the user in their cloud storage which Microsoft needs to prevent.
If this doesn't work, try using the Windows variables (
%USERPROFILE%
) to access the documents directory on the PC;
not the network.
Environment.ExpandEnvironmentVariables(String) Method (System) | Microsoft Docs[
^]
Edit
Oh, and unless you really want to allow the user to access/modify/process the data outside your application, why not use the app's local storage for a folder? I would recommend using
LocalApplicationData
as the entrypoint for such IO operations.
Try this enumeration to find out other possible folder names that your app can access and use,
Environment.SpecialFolder Enum (System) | Microsoft Docs[
^]