I use the following code to open jpg
-files:
var file = @"C:\Users\administrator.ADSALL4SPS\Desktop\IMG_4121.JPG";
var processStartInfo = new ProcessStartInfo { Verb = "open", FileName = file };
var workDir = Path.GetDirectoryName(file);
if (!string.IsNullOrEmpty(workDir)) {
processStartInfo.WorkingDirectory = workDir;
}
try {
Process.Start(processStartInfo);
} catch (Exception e) {
// Errorhandling
}
Now, when I do this, I get always an Win32Exception with NativeErrorCode = ERR_NO_ASSOCIATION
But the extension *.jpg
is associated to MSPaint.
When I double click the File then the File is opened in MSPaint.
Why is there a Win32Exception
even the file is associated?