Why Process.Start method always shows the "Open With" dialog

314 Views Asked by At

I'm working on a WPF application that use Process.Start() method to open images and PDF files with default viewer app.

What's the problem?

Every time I call Process.Start() method the "Open With" dialog shows up even if I check the "Always use this app to open .jpg files" option.

This is my C# code:

public void Open(string fileName, bool isPdf)
{
    var sharedFolderPath = AppCore.Settings.SharedFolder.Path;
    string message;

    if (sharedFolderPath is null)
    {
        message = Resources.EmptySharedFolderErrorMessage;
        AppCore.ShowDialog(AppCore.GetMessageDialog(message));
        return;
    }

    var path = Path.Combine(sharedFolderPath, fileName);

    if (File.Exists(path))
    {
        try
        {
            if (isPdf || AppCore.Settings.ImageViewerSettings.OpenInWindowsDefaultApp)
            {
                Process.Start(path);
            }
            else
            {
                var imageViewerWindow = new ImageViewerWindow(path);
                imageViewerWindow.ShowDialog();
            }
        }
        catch (Exception ex)
        {
            AppCore.Logger.Info("Opening shared file failed.");
            AppCore.Logger.Exception(ex);
        }

        return;
    }

    message = string.Format(Resources.SharedFolderFileNotFoundMessage, fileName);
    AppCore.ShowDialog(AppCore.GetMessageDialog(message));
}

My problem with more details: https://i.stack.imgur.com/FKWye.jpg

EDITED

I created a simple WPF project and tried to open the image with Process.Start() method. In the new project the image was opened with the default app without showing "Open With" dialog.

1

There are 1 best solutions below

0
On BEST ANSWER

I don't know why/how, but my problem solved after uninstalling TechSmith Snagit that I installed yesterday.