in my application i use
ManagementEventWatcher watcher = new ManagementEventWatcher(query);
ManagementBaseObject e = watcher.WaitForNextEvent();
string name = ((ManagementBaseObject)e["TargetInstance"])["Name"].ToString();
"name" is now "runfile.exe". when i use it later on, i need it without the ending: ".exe", so i used
name = Regex.Replace(name, ".exe", "");
my questione is, could there be run files which do not end in ".exe"? what about ".bat"? i am only concerned about files the user run himself to load the program, not installations and settings. could there be ".exe" in the middle of a run file name? if someone could just write a regular expression for run files on windows it would be grate. thank you so much.
You can use Path.GetFileNameWithoutExtension(fileName)
method.
MSDN Link: here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.