diff --git a/Post/Post/SqlFile.cs b/Post/Post/SqlFile.cs new file mode 100644 index 0000000000000000000000000000000000000000..90010a8541aca5edf28f94c11fcd200bdc464e34 --- /dev/null +++ b/Post/Post/SqlFile.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using System.IO; + +namespace Post +{ + public class SqlFile + { + public bool WriteFile(string ddlQuery, string alias) + { + bool isWrite = true; + string homePath = Environment.GetEnvironmentVariable("POST_HOME"); + Console.WriteLine("WriteFile : " + ddlQuery); + string path = String.Format(@"{0}\\sql\\{1}_{2}.sql", homePath, alias, @DateTime.Now.ToString("yyyyMMddHHmm")); + Console.WriteLine("path : " + path); + + try + { + using(File.Create(path)) + { + Console.WriteLine("파일 생성 성공"); + } + + StreamWriter writer = File.AppendText(path); + writer.WriteLine(ddlQuery); + writer.Close(); + Console.WriteLine("파일 작성 성공"); + } catch(Exception e) + { + Console.WriteLine("write file : " + e.ToString()); + return false; + } + return isWrite; + } + } +}