Main Content

WindowsPermissions

R2026b

Permissions of file, folder, or symbolic link in Windows

Since R2025a

Description

Use a WindowsPermissions object to view and edit the permissions of a file, folder, or symbolic link located on a Windows® system.

Creation

Create a WindowsPermissions object using the filePermissions function.

You can then view and edit individual permissions of the specified file, folder, or symbolic link by using the getPermissions and setPermissions functions, respectively.

Properties

expand all

This property is read-only.

Absolute path of the file, folder, or symbolic link, returned as a string scalar.

This property is read-only.

Type, returned as File, Folder, Symbolic Link, or None. Type is None if MATLAB® cannot resolve the path in AbsolutePath.

Readable permission, specified as a numeric or logical 1 (true) or 0 (false). A value of 1 indicates that the file, folder, or symbolic link is readable.

Writable permission, specified as a numeric or logical 1 (true) or 0 (false). A value of 1 indicates that the file, folder, or symbolic link is writable.

To write to a file on Windows, both Writable must be true and ReadOnly must be false.

Read-only file attribute, specified as a numeric or logical 1 (true) or 0 (false) (since R2026b). A value of 1 indicates that the file has the read-only attribute set. Set ReadOnly to false to allow write access to the file.

To write to a file on Windows, both Writable must be true and ReadOnly must be false.

Object Functions

getPermissionsGet individual permissions
setPermissionsSet individual permissions

Examples

collapse all

View the permissions of a file on a Windows operating system.

perms = filePermissions("example.txt")
perms =

          AbsolutePath        Type    Readable    Writable    ReadOnly
    ______________________    ____    ________    ________    ________

    "C:\Work\example.txt"     File      true        true       false  

Tips

  • On Windows systems, you can view permissions information in a Properties window by right-clicking a file, folder, or symbolic link and selecting Properties. The Properties window shows permissions under the Security tab, not in the Attributes section of the General tab.

Version History

Introduced in R2025a

expand all