public static string GetFilenameSafe(this Process process) {
try {
return GetProcessPathUsingPsApi(process.Id) ?? GetProcessPathUsingManagement(process.Id) ??
process.MainModule.FileName; // won’t work if processes were compiled for different architectures
} catch (Exception) {
return null;
}
}