FileIO.WriteBufferAsync(IStorageFile, IBuffer) 메서드

정의

버퍼의 데이터를 지정된 파일에 씁니다.

public:
 static IAsyncAction ^ WriteBufferAsync(IStorageFile ^ file, IBuffer ^ buffer);
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncAction WriteBufferAsync(IStorageFile const& file, IBuffer const& buffer);
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncAction WriteBufferAsync(IStorageFile file, IBuffer buffer);
function writeBufferAsync(file, buffer)
Public Shared Function WriteBufferAsync (file As IStorageFile, buffer As IBuffer) As IAsyncAction

매개 변수

file
IStorageFile

데이터 버퍼가 기록되는 파일입니다.

buffer
IBuffer

쓸 데이터가 들어 있는 버퍼입니다.

반환

이 메서드가 완료되면 개체 또는 값이 반환되지 않습니다.

특성

예제

파일 액세스 샘플에서는 을 사용하여 WriteBufferAsync 버퍼에서 파일로 데이터를 쓰는 방법을 보여줍니다.

try
{
    if (file != null)
    {
        IBuffer buffer = CryptographicBuffer.GenerateRandom(10);
        await FileIO.WriteBufferAsync(file, buffer);
        // Perform additional tasks after file is written
    }
}
// Handle errors with catch blocks
catch (FileNotFoundException)
{
    // For example, handle file not found
}

예제에서 는 file 쓸 파일을 나타내는 StorageFile 을 포함하는 지역 변수입니다.

메서드에 WriteBufferAsync 반환 값이 없지만 예제와 같이 텍스트가 파일에 기록된 후에도 추가 작업을 수행할 수 있습니다.

적용 대상