본문 바로가기

C#7

[C#, WPF] 폴더 선택 창 열고 사용하는 방법 (Folder Browser Dialog) - 코드 using System.Diagnostics; // Debug.WriteLine 사용 용도 System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog(); if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Debug.WriteLine(fbd.SelectedPath); } System.Windows.Forms.FolderBrowserDialog를 사용하기 위해서는 솔루션 탐색기에서 솔루션의 참조를 마우스 오른쪽 버튼을 클릭하여 참조 관리자를 열어 나오는 목록에서 체크하고 확인 버튼을 클릭하면 돼요. 만약에 참조 추가를 해주지 않고.. 2021. 5. 19.
[C#, WPF] 자기 자신의(실행 중인 프로그램)의 실행 경로 가져오는 방법 (실행 위치) * 코드 - 자기 자신(실행 중인 프로그램)의 실행 중인 경로 가져오기 string path = System.Reflection.Assembly.GetExecutingAssembly().Location; Debug.WriteLine(path); // 현재 실행중인 프로그램 명을 포함한 경로 path = System.IO.Path.GetDirectoryName(path); Debug.WriteLine(path); // 현재 실행중인 프로그램의 경로 * 실행 결과 D:\Test\WPF\WPF\bin\Debug\WPF_TEST.exe D:\Test\WPF\WPF\bin\Debug System.Reflection.Assembly.GetExecutingAssembly().Location; 는 현재 이 코드를 실행.. 2021. 3. 6.
[C#, WPF] INI 파일 쓰기, 읽는 방법 이번에는 C#에서 INI 파일을 쓰고, 읽어오는 방법에 대해서 알아보도록 할게요. * 코드 using System.Runtime.InteropServices; // INI 관련 [DllImport("kernel32")] private static extern long WritePrivateProfileString(string section, string key, string val, string filePath); [DllImport("kernel32")] private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath); .. 2021. 3. 6.
[C#] 네트워크 인터페이스 정보 가져오기 (랜 카드, NIC) 이번에는 네트워크 인터페이스(네트워크 카드, NIC)를 정보를 가져오는 방법에 대해서 알아보도록 할게요. # 코드 using System.Net.NetworkInformation; // Code NetworkInterface[] nicArray = NetworkInterface.GetAllNetworkInterfaces(); foreach (NetworkInterface nic in nicArray) { Debug.Print("{0} / {1} / {2} / {3}", nic.Name, nic.Description, nic.NetworkInterfaceType.ToString(), nic.Id); } # 실행 결과 이더넷 / Realtek PCIe GbE Family Controller / Etherne.. 2021. 3. 1.