Search code examples
c#processdefault-programs

Open url with IE instead of default browser


I have a app that when you click a button it opens a file that is on a SharePoint share. In IE it will open the document in word correctly that if you make changes to the file it will push the changes back to the SharePoint server, however if a user has Firefox as their default browser Firefox will download the file first then use the local copy. Is there a way to force the program to open the link in IE instead of the default browser (or to Word directly, however I need to pass the users domain credentials before I get access to the file)?

BackgroundWorker bw = new BackgroundWorker();
GeneratingChecklist frmProgressBar = new GeneratingChecklist();
frmProgressBar.Show();
bw.DoWork += (sender, e) =>
    {
        e.Result = Build(AccountNumber, PracticeName, ContractID, EducationDate, MainContactInfo, Address);
    };
bw.RunWorkerCompleted += (sender, e) =>
    {
        frmProgressBar.Close();
        running = false;
        if (e.Result != null)
        {
            System.Diagnostics.Process.Start(((FileDetails)e.Result).Address);
        }
        else
        {
            MessageBox.Show("An error occurred generating or retrieving the educator checklist.");
        }
    };
bw.RunWorkerAsync();

FileDetails.Address contrains the url to the word document.


Solution

  • Try:

    System.Diagnostics.Process.Start("iexplore.exe", "http://sp.path.to/your/file.doc")
    

    See the MSDN documentation for more information about opening processes with arguments.