<>C#

Method 1 :
string exePath = System.AppDomain.CurrentDomain.BaseDirectory; Console.
WriteLine(string.Format("exePath:{0}", exePath));
The result of running is
exePath:E:\dingdingDownload\DR2800_Print_TSN\DR2800_Print_TSN\bin\Debug\

Method 2 :
string path = System.IO.Directory.GetCurrentDirectory(); Console.WriteLine(
string.Format("path:{0}", path));
The result of running is :
path:E:\dingdingDownload\DR2800_Print_TSN\DR2800_Print_TSN\bin\Debug

be careful : The first method is to take the last \ Of , But the method does not take , They are all running programs .exe The absolute path of

<>C++
void CTestDlg::OnBnClickedButton2() { // TODO: Add control notification handler code here CString
strExePath{}; TCHAR szFilePath[MAX_PATH + 1]{}; GetModuleFileName(NULL,
szFilePath, MAX_PATH); // include exe The whole path of cout << "szFilePath :" << szFilePath << endl;
strExePath= szFilePath; unsigned long Length = 0; for (int i = 1; i <=
strExePath.GetLength(); i++) { CString temp = strExePath.Right(i); temp = temp.
Left(1); if (temp == _T("\\")) { Length = i; break; } } // except exe The absolute path of strExePath
= strExePath.Left(strExePath.GetLength() - Length); cout << "strExePath: " <<
strExePath<< endl; }
Results of running :

Technology
©2019-2020 Toolsou All rights reserved,
Huawei 2021 session Hardware Engineer Logical post (FPGA) Super detailed surface !!!Vue-element-admin upgrade ui edition virtual machine VMware Download and install the most detailed tutorial !C++ Move constructor and copy constructor sound of dripping water java Backstage interview pygame Realize full screen mode and adjustable window size mysql Database setting character set configuration modification my.ini file (windows)30 What's the experience of being a junior programmer at the age of 20 C++ Multithreading programming ( Summary of common functions and parameters )python_ cherry tree