共用方式為


FileActivatedEventArgs 類別

定義

在應用程式啟動時提供資料,因為它是與檔案相關聯的應用程式。

JAVAscript 此類型會顯示為 WebUIFileActivatedEventArgs

public ref class FileActivatedEventArgs sealed : IApplicationViewActivatedEventArgs, IFileActivatedEventArgsWithCallerPackageFamilyName, IFileActivatedEventArgsWithNeighboringFiles, IViewSwitcherProvider
public ref class FileActivatedEventArgs sealed : IActivatedEventArgsWithUser, IApplicationViewActivatedEventArgs, IFileActivatedEventArgsWithCallerPackageFamilyName, IFileActivatedEventArgsWithNeighboringFiles, IViewSwitcherProvider
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class FileActivatedEventArgs final : IApplicationViewActivatedEventArgs, IFileActivatedEventArgsWithCallerPackageFamilyName, IFileActivatedEventArgsWithNeighboringFiles, IViewSwitcherProvider
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class FileActivatedEventArgs final : IActivatedEventArgsWithUser, IApplicationViewActivatedEventArgs, IFileActivatedEventArgsWithCallerPackageFamilyName, IFileActivatedEventArgsWithNeighboringFiles, IViewSwitcherProvider
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class FileActivatedEventArgs : IApplicationViewActivatedEventArgs, IFileActivatedEventArgsWithCallerPackageFamilyName, IFileActivatedEventArgsWithNeighboringFiles, IViewSwitcherProvider
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class FileActivatedEventArgs : IActivatedEventArgsWithUser, IApplicationViewActivatedEventArgs, IFileActivatedEventArgsWithCallerPackageFamilyName, IFileActivatedEventArgsWithNeighboringFiles, IViewSwitcherProvider
Public NotInheritable Class FileActivatedEventArgs
Implements IApplicationViewActivatedEventArgs, IFileActivatedEventArgsWithCallerPackageFamilyName, IFileActivatedEventArgsWithNeighboringFiles, IViewSwitcherProvider
Public NotInheritable Class FileActivatedEventArgs
Implements IActivatedEventArgsWithUser, IApplicationViewActivatedEventArgs, IFileActivatedEventArgsWithCallerPackageFamilyName, IFileActivatedEventArgsWithNeighboringFiles, IViewSwitcherProvider
繼承
Object Platform::Object IInspectable FileActivatedEventArgs
屬性
實作

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

Application物件上的OnFileActivated事件處理常式會接收所有檔案啟用事件。

protected override void OnFileActivated(FileActivatedEventArgs args)
{
       // TODO: Handle file activation

       // The number of files received is args.Files.Size
       // The first file is args.Files[0].Name
}
Private Sub OnFileActivated(ByVal args As Windows.ApplicationModel.Activation.FileActivatedEventArgs)
      ' TODO: Handle file activation

      ' The number of files received is args.Files.Size
      ' The first file is args.Files(0).Name
End Sub
void App::OnFileActivated(Windows::ApplicationModel::Activation::FileActivatedEventArgs const& /* args */)
{
    // TODO: Handle file activation.

    // The number of files received is args.Files().Size().
    // The first file is args.Files().GetAt(0).Name().
}
void App::OnFileActivated(Windows::ApplicationModel::Activation::FileActivatedEventArgs^ args)
{
       // TODO: Handle file activation

       // The number of files received is args->Files->Size
       // The first file is args->Files->GetAt(0)->Name
}

備註

當您實作事件處理常式以在ActivationKindFile時回應Activated事件時,就會存取此物件。

使用 C++、C# 或 Visual Basic 的 UWP 應用程式通常會透過覆寫 Application 物件的方法來實作啟用點。 預設範本 app.xaml 程式碼後置檔案一律會包含 OnLaunched的覆寫,但定義其他啟用點的覆寫,例如 OnFileActivated ,取決於您的應用程式程式碼。

啟用案例中涉及的所有 應用程式 覆寫都應該在其實作中呼叫 Window.Activate

請注意,當您針對檔案合約啟用應用程式時,您必須使用透過Files屬性傳遞至應用程式的StorageFile物件來存取資料。 您不應該嘗試存取檔案的路徑,因為您的應用程式可能沒有檔案位置的許可權。

版本歷程記錄

Windows 版本 SDK 版本 已新增值
1607 14393 User

屬性

CallerPackageFamilyName

啟動應用程式之應用程式的套件系列名稱。

CurrentlyShownApplicationViewId

取得目前顯示之應用程式檢視的識別碼。

Files

取得啟動應用程式的檔案。

Kind

取得啟用類型。

NeighboringFilesQuery

取得啟動應用程式之檔案的鄰近檔案。

PreviousExecutionState

取得應用程式啟動前的執行狀態。

SplashScreen

取得啟動顯示畫面物件,提供從啟動顯示畫面轉換至啟動應用程式的相關資訊。

User

取得啟動應用程式的使用者。

Verb

取得與啟動檔案相關聯的動作。

ViewSwitcher

提供 物件,可讓您設定應用程式的檢視。

適用於

另請參閱