StorageFolder.Path 屬性

定義

如果路徑可用,則取得檔案系統中目前資料夾的完整路徑。

public:
 property Platform::String ^ Path { Platform::String ^ get(); };
winrt::hstring Path();
public string Path { get; }
var string = storageFolder.path;
Public ReadOnly Property Path As String

屬性值

String

Platform::String

winrt::hstring

如果路徑可用,則為檔案系統中目前資料夾的完整路徑。

實作

範例

下列範例會取得應用程式的安裝資料夾,並顯示資料夾的 Path 值。

using Windows.Storage;
using System.Diagnostics; // For writing results to the Output window.

// Get the app's installation folder.
StorageFolder appFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;

// Print the folder's path to the Visual Studio Output window.
Debug.WriteLine(appFolder.Name + " folder path: " + appFolder.Path);
// Get the app's installation folder.
Windows::Storage::StorageFolder appFolder{ Windows::ApplicationModel::Package::Current().InstalledLocation() };

// Print the path to the debug window.
::OutputDebugString(appFolder.Path().c_str());
// Get the app's installation folder
StorageFolder^ appFolder = Windows::ApplicationModel::Package::Current->InstalledLocation;

//Print the path to the debug window
String^ path = appFolder->Path;
OutputDebugString(path->Begin());

備註

請勿依賴這個屬性來存取資料夾,因為某些資料夾無法使用檔案系統路徑。 例如,在下列情況下,資料夾可能沒有檔案系統路徑,或者檔案系統路徑可能無法使用。

  • 例如,資料夾代表一組檔案的容器 (,例如 ,GetFoldersAsync 方法的某些多載傳回值) ,而不是檔案系統中的實際資料夾。
  • 資料夾是由 URI 所支援。
  • 資料夾是使用檔案選擇器挑選的。

適用於