PathIO 클래스

정의

파일의 절대 경로 또는 URI(Uniform Resource Identifier)를 사용하여 파일을 읽고 쓰는 도우미 메서드를 제공합니다.

public ref class PathIO abstract sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class PathIO final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public static class PathIO
Public Class PathIO
상속
Object Platform::Object IInspectable PathIO
특성

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)

예제

WriteTextAsync(filePathOrURI, contents)를 사용하여 파일에 텍스트를 쓸 수 있습니다. 예제 filePathOrURI 에서 는 읽을 파일에 대한 URI(예: 앱 URI "ms-appdata://sampleFile.dat") 또는 파일 시스템 경로(예: C:\examplepath\sampleFile.dat)를 포함하는 지역 변수입니다. WriteTextAsync 메서드에는 반환 값이 없지만 예제와 같이 텍스트가 파일에 기록된 후에도 추가 작업을 수행할 수 있습니다.

try
{
    if (file != null)
    {
        await PathIO.WriteTextAsync(filePathOrURI, "Swift as a shadow");
    }
}
// Handle errors with catch blocks
catch (FileNotFoundException)
{
    // For example, handle file not found
}

ReadTextAsync(filePathOrURI)를 사용하여 파일에서 텍스트를 읽을 수 있습니다. ReadTextAsync가 완료되면 변수는 fileContent 파일의 내용을 텍스트 문자열로 가져옵니다. 그런 다음 콘텐츠를 적절하게 처리할 수 있습니다.

try
{
    if (file != null)
    {
        string fileContent = await PathIO.ReadTextAsync(filePathOrURI);
    }
}
// Handle errors with catch blocks
catch (FileNotFoundException)
{
    // For example, handle file not found
}

관련 예제에 대한 자세한 내용은 파일 액세스 샘플FileIO를 참조하세요.

설명

경로 또는 URI(Uniform Resource Identifier)를 사용하여 파일을 읽거나 쓰려면 파일의 위치에 액세스할 수 있는 권한이 있어야 합니다. 앱에 액세스할 수 있는 권한이 있는 위치에 대한 자세한 내용은 파일 액세스 권한을 참조하세요.

앱 URI(Uniform Resource Identifier)를 지정하여 앱 데이터 폴더("ms-appdata://")와 같은 앱별 위치에서 파일을 읽거나 쓸 수 있습니다. 앱 URI(Uniform Resource Identifier)에 대한 자세한 내용은 콘텐츠를 참조하는 방법을 참조하세요.

메서드

AppendLinesAsync(String, IIterable<String>)

지정된 경로 또는 URI(Uniform Resource Identifier)의 파일에 텍스트 줄을 추가합니다.

AppendLinesAsync(String, IIterable<String>, UnicodeEncoding)

지정된 문자 인코딩을 사용하여 지정된 경로 또는 URI(Uniform Resource Identifier)의 파일에 텍스트 줄을 추가합니다.

AppendTextAsync(String, String)

지정된 경로 또는 URI(Uniform Resource Identifier)의 파일에 텍스트를 추가합니다.

AppendTextAsync(String, String, UnicodeEncoding)

지정된 문자 인코딩을 사용하여 지정된 경로 또는 URI(Uniform Resource Identifier)의 파일에 텍스트를 추가합니다.

ReadBufferAsync(String)

지정된 경로 또는 URI(Uniform Resource Identifier)에서 파일의 내용을 읽고 버퍼를 반환합니다.

ReadLinesAsync(String)

지정된 경로 또는 URI(Uniform Resource Identifier)에서 파일의 내용을 읽고 텍스트 줄을 반환합니다.

ReadLinesAsync(String, UnicodeEncoding)

지정된 문자 인코딩을 사용하여 지정된 경로 또는 URI(Uniform Resource Identifier)에서 파일의 내용을 읽고 텍스트 줄을 반환합니다.

ReadTextAsync(String)

지정된 경로 또는 URI(Uniform Resource Identifier)에서 파일의 내용을 읽고 텍스트를 반환합니다.

ReadTextAsync(String, UnicodeEncoding)

지정된 문자 인코딩을 사용하여 지정된 경로 또는 URI(Uniform Resource Identifier)에서 파일의 내용을 읽고 텍스트를 반환합니다.

WriteBufferAsync(String, IBuffer)

버퍼의 데이터를 지정된 경로 또는 URI(Uniform Resource Identifier)의 파일에 씁니다.

WriteBytesAsync(String, Byte[])

지정된 경로 또는 URI(Uniform Resource Identifier)의 파일에 단일 바이트 데이터를 씁니다.

WriteLinesAsync(String, IIterable<String>)

지정된 경로 또는 URI(Uniform Resource Identifier)의 파일에 텍스트 줄을 씁니다.

WriteLinesAsync(String, IIterable<String>, UnicodeEncoding)

지정된 문자 인코딩을 사용하여 지정된 경로 또는 URI(Uniform Resource Identifier)의 파일에 텍스트 줄을 씁니다.

WriteTextAsync(String, String)

지정된 경로 또는 URI(Uniform Resource Identifier)의 파일에 텍스트를 씁니다.

WriteTextAsync(String, String, UnicodeEncoding)

지정된 문자 인코딩을 사용하여 지정된 경로 또는 URI(Uniform Resource Identifier)의 파일에 텍스트를 씁니다.

적용 대상

추가 정보