파일을 생성하기 위해서 Manifest 파일에 추가
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="fileAccess.App">
<VisualElements DisplayName="fileAccess" Logo="Assets\Logo.png" SmallLogo="Assets\SmallLogo.png" Description="fileAccess" ForegroundText="light" BackgroundColor="#464646">
<DefaultTile ShowName="allLogos" />
<SplashScreen Image="Assets\SplashScreen.png" />
</VisualElements>
<Extensions>
<Extension Category="windows.fileTypeAssociation">
<FileTypeAssociation Name="test">
<SupportedFileTypes>
<FileType>.xml</FileType>
</SupportedFileTypes>
</FileTypeAssociation>
</Extension>
</Extensions>
</Application>
</Applications>
await 는 비동기 메소드에서 적용가능하다. ex) async void btnInsert_Click(object sender, RoutedEventArgs e)
파일 만들기
StorageFolder storageFolder = KnownFolders.DocumentsLibrary;
sampleFile = await storageFolder.CreateFileAsync("sample.xml", CreationCollisionOption.ReplaceExisting);
파일 쓰기
string content = "안녕하세요";
await FileIO.WriteTextAsync(sampleFile, content);
파일 읽기
string fileContent = await FileIO.ReadTextAsync(sampleFile);
파일삭제
if (sampleFile != null)
{
await sampleFile.DeleteAsync();
sampleFile = null;
}
'개발 공부 > C#' 카테고리의 다른 글
.net (c#) 에서 Standard TCP/IP over SSH 접속할때 (MySQL) (0) | 2014.03.01 |
---|---|
윈도우8 메트로앱 개발참조 - XML 생성하기 (0) | 2013.05.14 |