Read about environment getenvironmentvariable, The latest news, videos, and discussion topics about environment getenvironmentvariable from alibabacloud.com
Previously used GetWindowsDirectory, GetSystemDirectory, GetTempPath and other functions to obtain the system commonly used folders;Also used shgetspecialfolderlocation, shgetpathfromidlist function to obtain more common paths;But this is not as
Previously, we used functions such as getwindowsdirectory, getsystemdirectory, and gettemppath to obtain common system folders;
You have also used the shgetspecialfolderlocation and shgetpathfromidlist functions to obtain more common paths;
1. Obtain the path of the current file
1. system. Diagnostics. process. getcurrentprocess (). mainmodule. filename
Obtain the complete path of the module. Obtain the name of the currently executed EXE file.
2. system. environment.
1. Obtain the path of the current file
String str1 = process. getcurrentprocess (). mainmodule. filename; // Obtain the file name of the currently executed exe.String str2 = environment. currentdirectory; // Obtain and set the full path of the
1. Obtain the path of the current file1. System. Diagnostics. Process. GetCurrentProcess (). MainModule. FileName Obtain the complete path of the module, including the file name.2. System. Environment. CurrentDirectory Obtain and set the fully
1. Obtain the path of the current file
1. System. Diagnostics. Process. GetCurrentProcess (). MainModule. FileName
Obtain the complete path of the module, including the file name.
2. System. Environment. CurrentDirectory
Obtain and set the fully
Learning GoalsIn the previous section, we learned about processes, ingress functions, and process instance handles, and there was a wave of testing for a global variable initialization problem before going to the command line of the process to learn.
C # Seven methods for obtaining the current path,
Summary C # Seven methods for obtaining the current path
C # The method for obtaining the current path is as follows:
1. System. Diagnostics. Process. GetCurrentProcess (). MainModule. FileName
1. Obtain the path of the current file 1 . System. Diagnostics. process. getcurrentprocess (). mainmodule. filename: Obtain the complete path of the module, including the file name. 2 . System. environment. currentdirectory gets and sets the
1. Obtain the path of the current file
1. system. Diagnostics. process. getcurrentprocess (). mainmodule. filename: Obtain the complete path of the module, including the file name.
2. system. environment. currentdirectory gets and sets the fully
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.