Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I find thisd solution

I have picture saved in database and retrieved from database in picturebox...that working fine.

I need to show that picture in picture and fax viuwer

Error is : The system cant find file specified

 

Some help?


What I have tried:

private void button12_Click(object sender, EventArgs e)
        {
            Process photoViewer = new Process();
            photoViewer.StartInfo.FileName = @"c:\\testImage.jpg";
            photoViewer.StartInfo.Arguments = @"c:\\testImage.jpg";
            photoViewer.Start();


        }
Posted
Updated 4-Sep-18 6:00am

1 solution

Based on numerous replies, I begin to suspect you are not being very clear about what you hope to accomplish. I'll do my best to guess. That said, it would be easier, if you simply provided more detail in the question.

To view a file with an image viewer, you need to actually have a file. The file should be on-disk, not in memory. Because you specified "C:\testImage.jpg" in your question, I naturally assumed that you had already previously saved your image to disk. Your later responses, seem to indicate this may not be the case.

So, your first step, if the image is not already on disk, is to save it to disk. You don't mention what type of application (WinForm, WPF, WebForm, etc.).

For the purposes of this guess, I'll explain for WinForm. The way to save an JPEG image, from a WinForm picture box, to disk would be as follows:
string myPictures = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
string myPath = System.IO.Path.Combine(myPictures, "testImage.jpg");

pictureBox1.Image.Save(myPath, System.Drawing.Imaging.ImageFormat.Jpeg);

To display that image, using some image viewer...
// Use default image viewer
System.Diagnostics.Process.Start(myPath);

// Use image viewer application indicated by the variable "myImageViewer"
System.Diagnostics.Process.Start(myImageViewer, myPath);
 
Share this answer
 
v6
Comments
Goran Bibic 4-Sep-18 12:10pm    
private void button12_Click(object sender, EventArgs e)
{

new Process.Start(@"c:\\testImage.jpg");
}

error is Severity Code Description Project File Line Suppression State
Error CS0426 The type name 'Start' does not exist in the type 'Process'
Eric Lynch 4-Sep-18 12:17pm    
sorry...typo on my part...fixed.
Goran Bibic 4-Sep-18 12:19pm    
new Process().Start(@"c:\\testImage.jpg");

Severity Code Description Project File Line Suppression State
Error CS0176 Member 'Process.Start(string)' cannot be accessed with an instance reference; qualify it with a type name instead
Eric Lynch 4-Sep-18 12:19pm    
I'm having a bad day today...fixed for real and tested this time.
Goran Bibic 4-Sep-18 12:21pm    
Code no have errors, but in app when click on button :

The system cant find file specified!

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