39

I've tried this on both Windows 7 and Windows XP. Start Windows Explorer and create a new folder in some temporary location called (say) NonWriteable. Right-click the folder and set the properties of the folder to Read-only.

Folder set to be read-only

Now open the folder and create a new .txt file. This is allowed. Why? How do you set a folder so that nothing can be modified inside it?

Note: If I right-click the .txt file and set that to Read-only then the system correctly prevents updates to the file.

AlainD
  • 5,158

1 Answers1

57

Unlike the Read-only attribute for a file, the Read-only attribute for a folder is typically ignored by Windows, Windows components and accessories, and other programs. For example, you can delete, rename, and change a folder with the Read-only attribute by using Windows Explorer.

The Read-only and System attributes is only used by Windows Explorer to determine whether the folder is a special folder, such as a system folder that has its view customized by Windows (for example, My Documents, Favorites, Fonts, Downloaded Program Files), or a folder that you customized by using the Customize tab of the folder's Properties dialog box. As a result, Windows Explorer does not allow you to view or change the Read-only or System attributes of folders. When a folder has the Read-Only attribute set it causes Explorer to request the Desktop.ini of that folder to see if any special folder settings need to be set.

Source: https://support.microsoft.com/en-gb/help/326549/you-cannot-view-or-change-the-read-only-or-the-system-attributes-of-fo

This is an old article but it is still true for all versions of Windows.

To prevent the creation of files in a folder, change the permissions using the Security tab in the folder properties. Click the Advanced button and add a rule to deny access to Create Files / Write Data.