728x90
반응형
728x170
using System.IO;
using System.IO.IsolatedStorage;
using System.Windows;
namespace DS.Test.WPF
{
/// <summary>
/// 메인 애플리케이션
/// </summary>
public partial class MainApplication : Application
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary>
/// 파일 경로
/// </summary>
private string filePath = "Application.txt";
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Protected
#region 시작시 처리하기 - OnStartup(e)
/// <summary>
/// 시작시 처리하기
/// </summary>
/// <param name="e">이벤트 인자</param>
protected override void OnStartup(StartupEventArgs e)
{
IsolatedStorageFile isolatedStorageFile = IsolatedStorageFile.GetUserStoreForDomain();
try
{
using(IsolatedStorageFileStream isolatedStorageFileStream = new IsolatedStorageFileStream(this.filePath, FileMode.Open, isolatedStorageFile))
{
using(StreamReader streamReader = new StreamReader(isolatedStorageFileStream))
{
while(!streamReader.EndOfStream)
{
string[] keyValueArray = streamReader.ReadLine().Split(new char[] {','});
Properties[keyValueArray[0]] = keyValueArray[1];
}
}
}
}
catch(FileNotFoundException fileNotFoundException)
{
MessageBox.Show(fileNotFoundException.Message);
}
}
#endregion
#region 종료시 처리하기 - OnExit(e)
/// <summary>
/// 종료시 처리하기
/// </summary>
/// <param name="e">이벤트 인자</param>
protected override void OnExit(ExitEventArgs e)
{
IsolatedStorageFile isolatedStorageFile = IsolatedStorageFile.GetUserStoreForDomain();
using(IsolatedStorageFileStream isolatedStorageFileStream = new IsolatedStorageFileStream(this.filePath, FileMode.Create, isolatedStorageFile))
{
using(StreamWriter streamWriter = new StreamWriter(isolatedStorageFileStream))
{
foreach(string key in this.Properties.Keys)
{
streamWriter.WriteLine("{0},{1}", key, Properties[key]);
}
}
}
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] WPF 버전 번호가 저장된 레지스트리 키 (0) | 2014.01.30 |
---|---|
[C#/WPF] BrowserInteropHelper 클래스 : HostScript 속성을 사용해 XBAP 호스트 웹 페이지 통신하기 (0) | 2014.01.30 |
[C#/WPF] Button 클래스 : SetResourceReference 메소드를 사용해 리소스 설정하기 (0) | 2014.01.30 |
[C#/WPF] FrameworkElement 클래스 : TryFindResource 메소드를 사용해 리소스 찾기 (0) | 2014.01.30 |
[C#/WPF] FrameworkElement 클래스 : FindResource 메소드를 사용해 리소스 찾기 (0) | 2014.01.30 |
[C#/WPF] Application 클래스 : 리소스 구하기 (0) | 2014.01.30 |
[C#/WPF] ResourceDictionary 엘리먼트 사용하기 (0) | 2014.01.30 |
[C#/WPF] Application 클래스 : 애플리케이션 중지하기 (0) | 2014.01.29 |
[C#/WPF] NavigationService 클래스 : GoForward/GoBack 메소드 사용하기 (0) | 2014.01.29 |
[C#/WPF] PageFunction<T> 클래스 사용하기 (0) | 2014.01.29 |
댓글을 달아 주세요