<>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,
java Four functional interfaces ( a key , simple ) It's unexpected Python Cherry tree (turtle The gorgeous style of Library ) Browser kernel ( understand )HashMap Explain in detail Some East 14 Pay change 16 salary , Sincerity or routine ?html Writing about cherry trees , Writing about cherry trees