Latihan
Modul
Work with files and directories in a .NET app - Training
Learn how to use .NET, C#, and System.IO to work with directories, paths, files, and the file system.
Pelayar ini tidak lagi disokong.
Naik taraf kepada Microsoft Edge untuk memanfaatkan ciri, kemas kini keselamatan dan sokongan teknikal yang terkini.
In order to satisfy certain requirements, apps may require the files to appear in their existing install directory. For example, if a particular app was expecting a file in a folder, like C:\Program Files\Contoso; that directory can be modified by the admins. Starting in Windows 11, apps can specify a directory outside of the WindowsApps directory and the OS will ensure that files will appear in that location with proper ACLs inherited from the parent directory.
To enable this feature, the package will need to declare where to project the files in the package to. Below is an example
<Package...>
<Extensions>
<desktop8:Extension Category="windows.MutablePackageDirectories">
<desktop8:MutablePackageDirectories>
<desktop8:MutablePackageDirectory target="$(package.volumeroot)\Program Files\<Folder>" Shared=”true”>
</desktop8:MutablePackageDirectories>
</Extension>
</Extensions>
</Package>
Before using this feature, here are a list of considerations:
Considerations | Description |
---|---|
How to install a package with the ability to project? | Packages have to install through ProvisionPackageForAllUsers API |
Who can install it (users or admins)? | Admin |
Where can the files be projected to (locked location, or anywhere at all)? | Anywhere besides %pf%\windowsapps or %pf%\modifiablewindowsapps |
What are the ACLs on the projected directory if we create it? | Inherited from parent directory |
Can more than one package declare the same directory? | We do not allow more than one related set to declare the same directory. In other words, if there are multiple packages declaring the same directory, they must all be from the same related set. |
What about more than one publisher? | No |
How are collisions handled? | Packages and/or pre-existing files are merged. Conflicting files are resolved in specified priority order, or package-name alphabetically, if no order specified |
Latihan
Modul
Work with files and directories in a .NET app - Training
Learn how to use .NET, C#, and System.IO to work with directories, paths, files, and the file system.