using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WinFormStreamWriter
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SaveStreamWriter(DateTime.Now.ToString("yyyyMMddHHmmss") + ".log", "StreamWriter Test 내용");
}
public void SaveStreamWriter(string pFileName, string pTextStr)
{
try
{
string fleNm = Application.LocalUserAppDataPath + "\\" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".log";
using (StreamWriter sw = new StreamWriter(pFileName))
{
sw.WriteLine("---------------------------------------------------------------------");
sw.WriteLine(pTextStr);
sw.WriteLine("---------------------------------------------------------------------");
sw.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}