WindowsRuntimeStorageExtensions.CreateSafeFileHandle 메서드

정의

확장 중인 IStorage 인스턴스의 안전 파일 핸들에 대한 참조를 만들어 반환합니다.

오버로드

CreateSafeFileHandle(IStorageFolder, String, FileMode)

현재 스토리지 폴더 인스턴스에 있는 파일의 안전한 파일 핸들을 만듭니다.

CreateSafeFileHandle(IStorageFile, FileAccess, FileShare, FileOptions)

현재 스토리지 파일 인스턴스의 안전한 파일 핸들을 만듭니다.

CreateSafeFileHandle(IStorageFolder, String, FileMode, FileAccess, FileShare, FileOptions)

현재 스토리지 폴더 인스턴스에 있는 파일의 안전한 파일 핸들을 만듭니다.

설명

Windows 10 1주년 업데이트를 사용하면 표준 Win32 파일 핸들 IStorageFolderHandleAccess 을 만들 수 있는 새 인터페이스가 IStorageItemHandleAccess추가 IStorageFolder IStorageFile 되었습니다. CreateSafeFileHandle 확장 메서드 그룹은 이러한 인터페이스의 메서드를 Create 활용합니다.

API의 주요 이점은 조정된 SafeFileHandle사용자에 대한 액세스입니다. 주변을 만들 FileStream IStorageItem IStorageFolder 거나 AppContainer에서 실행 중인 경우 이는 매우 중요합니다. AppContainer에서 실행할 때 애플리케이션에는 매우 제한된 파일 액세스 권한이 있습니다. 응용 프로그램 프로세스 자체에는 대부분의 파일에 대한 권한이 없으므로 그림 및 문서 폴더와 같은 작업을 수행하려면 네이티브 파일 핸들을 통해 RuntimeBroker.exe프록시해야 합니다. 이 API는 프록시 핸들을 가져옵니다. 사용자 데이터 폴더에 액세스하거나 파일 선택기를 사용하는 경우 이 API를 항상 사용하여 만들어야 FileStream합니다. 경로 사용은 이러한 경우에 throw AccessViolationException 되는 경우가 많습니다.

CreateSafeFileHandle(IStorageFolder, String, FileMode)

중요

이 API는 CLS 규격이 아닙니다.

현재 스토리지 폴더 인스턴스에 있는 파일의 안전한 파일 핸들을 만듭니다.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Win32::SafeHandles::SafeFileHandle ^ CreateSafeFileHandle(Windows::Storage::IStorageFolder ^ rootDirectory, System::String ^ relativePath, System::IO::FileMode mode);
[System.CLSCompliant(false)]
public static Microsoft.Win32.SafeHandles.SafeFileHandle CreateSafeFileHandle (this Windows.Storage.IStorageFolder rootDirectory, string relativePath, System.IO.FileMode mode);
[<System.CLSCompliant(false)>]
static member CreateSafeFileHandle : Windows.Storage.IStorageFolder * string * System.IO.FileMode -> Microsoft.Win32.SafeHandles.SafeFileHandle
<Extension()>
Public Function CreateSafeFileHandle (rootDirectory As IStorageFolder, relativePath As String, mode As FileMode) As SafeFileHandle

매개 변수

rootDirectory
IStorageFolder

현재 스토리지 폴더 인스턴스입니다.

relativePath
String

처리하려는 파일의 이름입니다.

mode
FileMode

운영 체제에서 파일을 열어야 하는 모드입니다.

반환

SafeFileHandle

작업에 성공하면 안전한 파일 핸들 인스턴스이고, rootDirectory를 IStorageFolderHandleAccess로 변환하는 작업에서 null을 반환하면 null입니다.

특성

예외

rootDirectory이(가) null인 경우

또는

relativePath이(가) null인 경우

설명

이 메서드를 호출할 때 지정된 모드인 FileMode.Append경우 액세스 권한으로 FileAccess.Read 파일이 열립니다. 다른 모드의 경우 액세스 권한으로 FileAccess.ReadWrite 파일이 열립니다.

또한 이 메서드는 스트림 공유 액세스 권한 및 FileShare.Read 고급 파일 만들기 옵션을 사용하여 FileOptions.None 파일을 엽니다.

적용 대상

CreateSafeFileHandle(IStorageFile, FileAccess, FileShare, FileOptions)

중요

이 API는 CLS 규격이 아닙니다.

현재 스토리지 파일 인스턴스의 안전한 파일 핸들을 만듭니다.

[System.CLSCompliant(false)]
public static Microsoft.Win32.SafeHandles.SafeFileHandle CreateSafeFileHandle (this Windows.Storage.IStorageFile windowsRuntimeFile, System.IO.FileAccess access = System.IO.FileAccess.ReadWrite, System.IO.FileShare share = System.IO.FileShare.Read, System.IO.FileOptions options = System.IO.FileOptions.None);
[<System.CLSCompliant(false)>]
static member CreateSafeFileHandle : Windows.Storage.IStorageFile * System.IO.FileAccess * System.IO.FileShare * System.IO.FileOptions -> Microsoft.Win32.SafeHandles.SafeFileHandle
<Extension()>
Public Function CreateSafeFileHandle (windowsRuntimeFile As IStorageFile, Optional access As FileAccess = System.IO.FileAccess.ReadWrite, Optional share As FileShare = System.IO.FileShare.Read, Optional options As FileOptions = System.IO.FileOptions.None) As SafeFileHandle

매개 변수

windowsRuntimeFile
IStorageFile

스토리지 파일 인스턴스입니다.

access
FileAccess

파일을 열 때 사용해야 하는 액세스 유형입니다. 기본값은 ReadWrite입니다.

share
FileShare

다른 FileStream 개체가 동일한 파일에 대해 가질 수 있는 스트림 공유 액세스 유형입니다. 기본값은 Read입니다.

options
FileOptions

FileStream 개체를 만드는 데 사용하는 고급 옵션입니다. 기본값은 None입니다.

반환

SafeFileHandle

작업에 성공하면 안전한 파일 핸들 인스턴스이고, windowsRuntimeFile를 IStorageItemHandleAccess로 변환하는 작업에서 null을 반환하면 null입니다.

특성

예외

windowsRuntimeFile이(가) null인 경우

적용 대상

CreateSafeFileHandle(IStorageFolder, String, FileMode, FileAccess, FileShare, FileOptions)

중요

이 API는 CLS 규격이 아닙니다.

현재 스토리지 폴더 인스턴스에 있는 파일의 안전한 파일 핸들을 만듭니다.

[System.CLSCompliant(false)]
public static Microsoft.Win32.SafeHandles.SafeFileHandle CreateSafeFileHandle (this Windows.Storage.IStorageFolder rootDirectory, string relativePath, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share = System.IO.FileShare.Read, System.IO.FileOptions options = System.IO.FileOptions.None);
[<System.CLSCompliant(false)>]
static member CreateSafeFileHandle : Windows.Storage.IStorageFolder * string * System.IO.FileMode * System.IO.FileAccess * System.IO.FileShare * System.IO.FileOptions -> Microsoft.Win32.SafeHandles.SafeFileHandle
<Extension()>
Public Function CreateSafeFileHandle (rootDirectory As IStorageFolder, relativePath As String, mode As FileMode, access As FileAccess, Optional share As FileShare = System.IO.FileShare.Read, Optional options As FileOptions = System.IO.FileOptions.None) As SafeFileHandle

매개 변수

rootDirectory
IStorageFolder

현재 스토리지 폴더 인스턴스입니다.

relativePath
String

처리하려는 파일의 이름입니다.

mode
FileMode

운영 체제에서 파일을 열어야 하는 모드입니다.

access
FileAccess

파일을 열 때 사용해야 하는 액세스 유형입니다.

share
FileShare

다른 FileStream 개체가 동일한 파일에 대해 가질 수 있는 스트림 공유 액세스 유형입니다. 기본값은 Read입니다.

options
FileOptions

FileStream 개체를 만드는 데 사용하는 고급 옵션입니다. 기본값은 None입니다.

반환

SafeFileHandle

작업에 성공하면 안전한 파일 핸들 인스턴스이고, rootDirectory를 IStorageFolderHandleAccess로 변환하는 작업에서 null을 반환하면 null입니다.

특성

예외

rootDirectory이(가) null인 경우

또는

relativePath이(가) null인 경우

적용 대상