Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I downloaded a JpegViewer program. I tested it by typing JpegViewer.exe file.jpg and it works fine. My problem is, when I attempt to call it from my C# form app, it calls the standard MS Paint program instead of the Jpegviewer. Can someone please explain what is happening and how I can resolve this issue?

Thank you.

C#
if (e.RowIndex < 0)
              return;
          int rowIndex = e.RowIndex;
          DataGridViewRow row = dataGridView1.Rows[rowIndex];
          String location = @Folder + @"\" + Facility + @"\" + row.Cells[6].Value.ToString() + @"\" + row.Cells[0].Value.ToString();

          if (row.Cells[5].Value.ToString().ToUpper() == "PDF")
          {
              System.Diagnostics.Process.Start(Adobe, location);
          }

          if (row.Cells[5].Value.ToString().ToUpper() == "JPG")
          {
          //    System.Diagnostics.Process.Start("MSPAINT.exe", location);
         // This line opens the Jpeg file with Windows PAINT instead of jpegviewer
         System.Diagnostics.Process.Start("c:\\windows\\system32\\jpegviewer.exe ", location);
          }
Posted
Comments
Bernhard Hiller 19-Jul-13 2:40am    
Your code looks not wrong to me. Are you sure jpegviewer.exe is installed in system32?
And what's your OS - also bitness - and the target platform of your program?

1 solution

It simply depends on what is setup in your system registry for the said file types. Most typically, you change it in the installation package of your software.

See, for example, this CodeProject article on how it can be done in C#: System File Association[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900