共用方式為


企業共用存放裝置

共用存放裝置由兩個位置組成,其中具有受限功能 enterpriseDeviceLockdown 和 Enterprise 憑證的應用程式具有完整讀取和寫入存取權。 請注意,enterpriseDeviceLockdown 功能可讓應用程式使用裝置鎖定 API,並存取企業共用存放裝置資料夾。 如需 API 的詳細資訊,請參閱 Windows.Embedded.DeviceLockdown 命名空間。

這些位置是在本機磁碟機上設定:

  • \Data\SharedData\Enterprise\Persistent
  • \Data\SharedData\Enterprise\Non-Persistent

案例

企業共用存放裝置支援以下場景。

  • 您可以在應用程式的執行個體內、同一應用程式的執行個體之間甚至應用程式之間共用資料 (假設它們都具有適當的功能和憑證)。
  • 您可以將資料儲存在本機硬碟的 \Data\SharedData\Enterprise\Persistent 資料夾中,即使在裝置重設後,資料仍然存在。
  • 操作檔案,包括透過行動裝置管理 (MDM) 服務讀取、寫入和刪除裝置上的檔案。

存取企業共用存放裝置

以下範例示範如何在套件清單中宣告存取企業共用儲存的功能,以及如何使用 Windows.Storage.StorageFolder 類別存取共用儲存資料夾。

在您的應用程式包清單中,包含以下功能:

<Package
  xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
  xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
  xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
  IgnorableNamespaces="uap mp rescap">

…

<Capabilities>
    <rescap:Capability Name="enterpriseDeviceLockdown"/>
</Capabilities>

若要存取共用資料位置,您的應用程式將使用以下程式碼。

using System;
using System.Collections.Generic;
using System.Diagnostics;
using Windows.Storage;

…

// Get the Enterprise Shared Storage folder.
var enterprisePersistentFolderRoot = @"C:\Data\SharedData\Enterprise\Persistent";

StorageFolder folder =
    await StorageFolder.GetFolderFromPathAsync(enterprisePersistentFolderRoot);

// Get the files in the folder.
IReadOnlyList<StorageFile> sortedItems =
    await folder.GetFilesAsync();

// Iterate over the results and print the list of files
// to the Visual Studio Output window.
foreach (StorageFile file in sortedItems)
    Debug.WriteLine(file.Name + ", " + file.DateCreated);