ConfigForm.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using Microsoft.Win32;
  2. using System;
  3. using System.IO;
  4. using System.Windows.Forms;
  5. namespace CLIP.eForm.Consent.UI
  6. {
  7. public partial class ConfigForm : Form
  8. {
  9. public ConfigForm()
  10. {
  11. InitializeComponent();
  12. }
  13. protected override void OnLoad(EventArgs e)
  14. {
  15. //현재 프로그램이 실행되고 있는정보 가져오기: 디버깅 모드라면 bin/debug/프로그램명.exe
  16. FileInfo exefileinfo = new FileInfo(Path.GetDirectoryName(Application.StartupPath));
  17. // AppDomain.CurrentDomain.DynamicDirectory
  18. // Server.MapPath("~")
  19. string path = Path.GetDirectoryName(Application.StartupPath);//@"C:\eForm Server\Consent-Web-Server-CNUH\";// HttpContext.Current.Request.PhysicalApplicationPath;
  20. string fileName = @"\config.ini"; //파일명
  21. //만약 현재 실행 되는 경로가 아닌 특정한 위치를 원한다면 위에 과정 상관없이 바로 경로셋팅 해 주면 된다. (예: c:\config.ini)
  22. string filePath = path + fileName; //ini 파일 경로
  23. iniUtil ini = new iniUtil(filePath); // 만들어 놓았던 iniUtil 객체 생성(생성자 인자로 파일경로 정보 넘겨줌)
  24. //이제 ini 객체를 이용해 맘것 사용하면 된다.
  25. string sMoniterNumber = ini.GetIniValue("DFH", "MONITER_NUMBER");
  26. decimal iMoniterNumber = 1;
  27. if (decimal.TryParse(sMoniterNumber, out iMoniterNumber))
  28. {
  29. this.numericUpDownMoniterNumberNumber.Value = iMoniterNumber;
  30. }
  31. base.OnLoad(e);
  32. }
  33. private void btnOK_Click(object sender, EventArgs e)
  34. {
  35. //현재 프로그램이 실행되고 있는정보 가져오기: 디버깅 모드라면 bin/debug/프로그램명.exe
  36. FileInfo exefileinfo = new FileInfo(Path.GetDirectoryName(Application.StartupPath));
  37. // AppDomain.CurrentDomain.DynamicDirectory
  38. // Server.MapPath("~")
  39. string path = Path.GetDirectoryName(Application.StartupPath);//@"C:\eForm Server\Consent-Web-Server-CNUH\";// HttpContext.Current.Request.PhysicalApplicationPath;
  40. string fileName = @"\config.ini"; //파일명
  41. //만약 현재 실행 되는 경로가 아닌 특정한 위치를 원한다면 위에 과정 상관없이 바로 경로셋팅 해 주면 된다. (예: c:\config.ini)
  42. string filePath = path + fileName; //ini 파일 경로
  43. iniUtil ini = new iniUtil(filePath); // 만들어 놓았던 iniUtil 객체 생성(생성자 인자로 파일경로 정보 넘겨줌)
  44. //이제 ini 객체를 이용해 맘것 사용하면 된다.
  45. ini.SetIniValue("DFH", "MONITER_NUMBER", this.numericUpDownMoniterNumberNumber.Value.ToString());
  46. this.Close();
  47. }
  48. }
  49. }