たとえば何かファイルを作成して読み取り専用にした後、ハードリンクを作成し、一方のファイルを削除すると、確かに残ったファイルの読み取り専用属性が解除されている。
重要 ハードリンク移行ストアを削除すると、移行後のファイルの読み取り専用ファイル属性が解除されます。これは、NTFS ファイル システムのハード リンクの制限によるものです。
C:\TEMP>fsutil file createnew temp.txt 1 ファイル C:\TEMP\temp.txt が作成されました C:\TEMP>attrib +r temp.txt C:\TEMP>fsutil hardlink create temp2.txt temp.txt C:\TEMP\temp2.txt <<===>> C:\TEMP\temp.txt のハードリンクが作成されました C:\TEMP>fileinfo.exe *.* <DIR> 1 3ce6dafa:0021000000000081 . <DIR> 1 3ce6dafa:0005000000000005 .. A R 2 3ce6dafa:003400000000aeec temp.txt A R 2 3ce6dafa:003400000000aeec temp2.txt (ここでexplorerでtemp.txtを削除) C:\TEMP>fileinfo.exe *.* <DIR> 1 3ce6dafa:0021000000000081 . <DIR> 1 3ce6dafa:0005000000000005 .. A 1 3ce6dafa:003400000000aeec temp2.txt C:\TEMP> |
もどるRemarks
If an application attempts to delete a file that does not exist, the DeleteFile function fails with ERROR_FILE_NOT_FOUND. If the file is a read-only file, the function fails with ERROR_ACCESS_DENIED.
The following list identifies some tips for deleting, removing, or closing files:
- To delete a read-only file, first you must remove the read-only attribute.
- To delete or rename a file, you must have either delete permission on the file, or delete child permission in the parent directory.
- To recursively delete the files in a directory, use the SHFileOperation function.
- To remove an empty directory, use the RemoveDirectory function.
- To close an open file, use the CloseHandle function.
If you set up a directory with all access except delete and delete child, and the access control lists (ACL) of new files are inherited, then you can create a file without being able to delete it. However, then you can create a file, and then get all the access you request on the handle that is returned to you at the time you create the file.
If you request delete permission at the time you create a file, you can delete or rename the file with that handle, but not with any other handle. For more information, see File Security and Access Rights.
The DeleteFile function fails if an application attempts to delete a file that is open for normal I/O or as a memory-mapped file.
The DeleteFile function marks a file for deletion on close. Therefore, the file deletion does not occur until the last handle to the file is closed. Subsequent calls to CreateFile to open the file fail with ERROR_ACCESS_DENIED.
Symbolic link behavior—
If the path points to a symbolic link, the symbolic link is deleted, not the target. To delete a target, you must call CreateFile and specify FILE_FLAG_DELETE_ON_CLOSE.