본문 바로가기

프로그래밍/C#, WPF, .Net16

[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.
[C#] 소스 코드 실행 시간 측정하는 방법 이번에는 C#에서 소스 코드의 실행 시간을 측정하는 방법에 대해서 알아보도록 할게요. # 코드 using System.Diagnostics; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); // 시간을 측정할 부분 Thread.Sleep(1000); // 1초 대기 stopwatch.Stop(); Debug.WriteLine(stopwatch.ElapsedMilliseconds + " ms"); # 결과 1000 ms 2021. 2. 28.