LauncherOptions.ContentType 속성

정의

네트워크의 파일을 나타내는 URI와 연결된 콘텐츠 형식을 가져오거나 설정합니다.

public:
 property Platform::String ^ ContentType { Platform::String ^ get(); void set(Platform::String ^ value); };
winrt::hstring ContentType();

void ContentType(winrt::hstring value);
public string ContentType { get; set; }
var string = launcherOptions.contentType;
launcherOptions.contentType = string;
Public Property ContentType As String

속성 값

String

Platform::String

winrt::hstring

URI의 콘텐츠 형식입니다.

예제

ContentType이 시작 중인 URI와 연결된 콘텐츠 형식으로 설정된 Launcher.LaunchUriAsync(Uri, LauncherOptions) 메서드를 호출합니다.

// The URI to launch
string uriToLaunch = @"http://www.contoso.com/SomeFile.docx";
var uri = new Uri(uriToLaunch);

async void DefaultLaunch()
{
   // Set the URI's content type
   var options = new Windows.System.LauncherOptions();
   options.ContentType = "application/vnd.ms-word.document.12";

   // Launch the URI with the content type
   var success = await Windows.System.Launcher.LaunchUriAsync(uri, options);

   if (success)
   {
      // URI launched
   }
   else
   {
      // URI launch failed
   }
}
// The URI to launch.
Windows::Foundation::Uri m_uri{ L"http://www.contoso.com/SomeFile.docx" };

Windows::Foundation::IAsyncAction MainPage::DefaultLaunch()
{
    // Set the URI's content type.
    Windows::System::LauncherOptions launcherOptions;
    launcherOptions.ContentType(L"application/vnd.ms-word.document.12");

    // Launch the URI.
    if (co_await Windows::System::Launcher::LaunchUriAsync(m_uri, launcherOptions))
    {
        // URI launched.
    }
    else
    {
        // URI launch failed.
    }
}
// The URI to launch.
auto uri = ref new Windows::Foundation::Uri("http://www.contoso.com/SomeFile.docx");

void MainPage::DefaultLaunch()
{
   // Set the URI's content type
   auto launchOptions = ref new Windows::System::LauncherOptions();
   launchOptions->ContentType = "application/vnd.ms-word.document.12";

   // Launch the URI with the content type
   concurrency::task<bool> launchUriOperation(Windows::System::Launcher::LaunchUriAsync(uri, launchOptions));
   launchUriOperation.then([](bool success)
   {
      if (success)
      {
         // URI launched
      }
      else
      {
         // URI launch failed
      }
   });
}
' The URI to launch
Dim uri As New Uri("http://www.contoso.com/SomeFile.docx")

async Sub DefaultLaunch()

   ' Set the URI's content type
   Dim options = Windows.System.LauncherOptions()
   options.ContentType = "application/vnd.ms-word.document.12"

   ' Launch the URI with the content type
   Dim success = await Windows.System.Launcher.LaunchUriAsync(uri, options)

   If success Then
      ' URI launched
   Else
      ' URI launch failed
   End If

End Sub

설명

ContentType은 Launcher.LaunchUriAsync(Uri, LauncherOptions)를 사용하여 URI를 시작할 때만 지정할 수 있습니다.

ContentType 속성을 사용하면 앱에서 콘텐츠 형식과 함께 URI를 지정할 수 있습니다. 이를 사용하여 네트워크의 리소스를 가리키는 URI를 URI 스키마 이름 대신 파일 형식과 연결할 수 있습니다. Windows는 콘텐츠 형식에서 계산된 파일 형식을 사용하여 시작할 앱을 선택합니다. 그런 다음 기본 파일 처리기는 파일 경로 대신 URI를 전달합니다. 예를 들어 .docx 파일을 가리키는 http:// URI가 있는 경우 파일을 클릭하면 일반적으로 브라우저가 열리고 파일 다운로드가 시작됩니다. ContentType 속성을 사용하면 중간 단계를 건너뛰고 기본 파일 처리기를 즉시 시작할 수 있습니다. 그런 다음, 파일 처리기는 URI에 포함된 경로를 사용하여 네트워크의 파일에 직접 액세스할 수 있습니다.

처리기가 URI에서 직접 작업할 수 없는 경우 파일 복사본이 대신 다운로드됩니다.

ContentType을 사용하면 파일 처리기를 직접 시작할 수 있으므로 이 옵션을 지정하여 파일 시작에 적용되는 것과 동일한 보안 검사가 URI 시작에 적용됩니다. 이러한 보안 검사 에 대한 자세한 내용은 파일에 대한 기본 앱 시작을 참조하세요.

참고

이 기능은 기본 파일 처리기가 네트워크의 파일에 URI 전달을 지원하는 경우에만 작동합니다. 기본 파일 처리기는 파일의 서버로 인증할 수도 있어야 합니다. 이러한 제한 사항 때문에 앱과 실행 중인 파일을 처리할 것으로 예상되는 앱 간의 종단 간 시나리오를 철저히 테스트한 경우에만 ContentType 속성을 사용해야 합니다.

중요

이 속성은 데스크톱 디바이스에서만 구현됩니다.

적용 대상

추가 정보