Open image in Windows Photo Viewer
How to open .jpg
image in Windows Photo Viewer from C# app?
Not inside app like this code,
FileStream stream = new FileStream("test.png", FileMode.Open, FileAccess.Read);
pictureBox1.Image = Image.FromStream(stream);
stream.Close();
Solution 1:
I think you can just use:
Process.Start(@"C:\MyPicture.jpg");
And this will use the standard file viewer associated with .jpg files - by default the windows picture viewer.
Solution 2:
Start it in a new Process
Process photoViewer = new Process();
photoViewer.StartInfo.FileName = @"The photo viewer file path";
photoViewer.StartInfo.Arguments = @"Your image file path";
photoViewer.Start();
Solution 3:
The code fetch photo from ftp and shows the photo in Windows Photo Viewer. I hope it will usefully for you.
public void ShowPhoto(String uri, String username, String password)
{
WebClient ftpClient = new WebClient();
ftpClient.Credentials = new NetworkCredential(username,password);
byte[] imageByte = ftpClient.DownloadData(uri);
var tempFileName = Path.GetTempFileName();
System.IO.File.WriteAllBytes(tempFileName, imageByte);
string path = Environment.GetFolderPath(
Environment.SpecialFolder.ProgramFiles);
// create our startup process and argument
var psi = new ProcessStartInfo(
"rundll32.exe",
String.Format(
"\"{0}{1}\", ImageView_Fullscreen {2}",
Environment.Is64BitOperatingSystem ?
path.Replace(" (x86)", "") :
path
,
@"\Windows Photo Viewer\PhotoViewer.dll",
tempFileName)
);
psi.UseShellExecute = false;
var viewer = Process.Start(psi);
// cleanup when done...
viewer.EnableRaisingEvents = true;
viewer.Exited += (o, args) =>
{
File.Delete(tempFileName);
};
}
Best Regards...