728x90
728x170
■ IsolatedStorageFile 클래스를 사용해 격리된 저장소에서 텍스트 파일을 생성하는 방법을 보여준다.
▶ 예제 코드 (C#)
using System.IO;
using System.IO.IsolatedStorage;
#region 파일 쓰기 - WrieFile(fileName, message)
/// <summary>
/// 파일 쓰기
/// </summary>
/// <param name="fileName">파일명</param>
/// <param name="message">메시지</param>
public void WrieFile(string fileName, string message)
{
IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForAssembly();
using(IsolatedStorageFileStream stream = new IsolatedStorageFileStream(fileName, FileMode.Create, file))
{
using(StreamWriter writer = new StreamWriter(stream))
{
writer.WriteLine(message);
}
}
}
#endregion
※ 격리된 저장소 파일은 아래 디렉토리의 하위에 저장된다.
C:\Users\계정명\AppData\Local\IsolatedStorage
728x90
그리드형(광고전용)
'C# > Common' 카테고리의 다른 글
[C#/COMMON] 원 숫자 문자열 구하기 (0) | 2020.09.23 |
---|---|
[C#/COMMON] DateTimeFormatInfo 클래스 : FirstDayOfWeek 속성을 사용해 주의 첫째 요일 구하기 (0) | 2020.08.27 |
[C#/COMMON] Type 클래스 : IsSubclassOf 메소드를 사용해 특정 타입의 파생 타입 여부 구하기 (0) | 2020.08.26 |
[C#/COMMON] Assembly 클래스 : GetTypes 메소드를 사용해 어셈블리가 갖고 있는 타입 배열 구하기 (0) | 2020.08.26 |
[C#/COMMON] Assembly 클래스 : GetAssembly 정적 메소드를 사용해 특정 타입을 갖는 어셈블리 구하기 (0) | 2020.08.26 |
[C#/COMMON] IsolatedStorageFile 클래스 : 격리된 저장소에서 로그 파일에 로그 추가하기 (0) | 2020.08.21 |
[C#/COMMON] Environment 클래스 : GetCommandLineArgs 정적 메소드를 사용해 명령행 인자 구하기 (0) | 2020.08.19 |
[C#/COMMON] 포맷 문자열을 사용해 숫자 앞에 0으로 채우기 (0) | 2020.08.18 |
[C#/COMMON] ManagementObject 클래스 : InvokeMethod 메소드를 사용해 디폴트 프린터 설정하기 (0) | 2020.08.18 |
[C#/COMMON] JavaScriptSerializer 클래스 : Serialize 메소드를 사용해 JSON 문자열 구하기 (0) | 2020.08.18 |