Click here to Skip to main content
15,885,908 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ProcessStartInfo startInfo = new ProcessStartInfo();

startInfo.FileName = @"c:\windows\system32\rundll32.exe";

startInfo.Arguments =
@"C:\WINDOWS\System32\shimgvw.dll,ImageView_Fullscreen C:\Users\Sony\Desktop\c.jpg"


I want to specify the image URI (C:\Users\Sony\Desktop\c.jpg)as a string variable.So what changes do I have to make in startInfo.Arguments.
Posted

Hi,

Try this:
C#
startInfo.Arguments =
@"C:\WINDOWS\System32\shimgvw.dll,ImageView_Fullscreen \"" + filenameStringVariable + "\""; // change 'filenameStringVariable' into the name of your string variable

Hope this helps.

[EDIT #2]String surrounded with quotes, as Steve44 recommended.[/EDIT]
[EDIT]

If you want to open a photo in a photo viewer, then you can try this:
C#
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = filenameStringVariable;
Process.Start(startInfo);

This code opens the file with the default application of the file. If the file is a picture, then a picture viewer will open the picture.
 
Share this answer
 
v3
Comments
Member 9805113 12-Apr-13 5:15am    
I have tried that but the photo viewer itself doesn't open.
Thomas Daniels 12-Apr-13 5:28am    
I updated my answer.
Steve44 12-Apr-13 5:30am    
Does it work in your static sample above?
Does your file path or name contain spaces? In this case you would have to surround the string with quotes within the string:
@"C:\WINDOWS\System32\shimgvw.dll,ImageView_Fullscreen \"" + filenameStringVariable "\"";
This is recommended in general.
Member 9805113 12-Apr-13 6:05am    
No.I dont have spaces in file path. The process starts and closes immediately.It does not open through photo viewer and image does not get displayed.
C#
static void OpenImage()
        {
            //string path = @"C:\Users\Desktop\Skype_Files\abc.jpg";
            //System.Diagnostics.Process.Start(path);


            string Path = @"C:\Users\Desktop\Skype_Files\abc.jpg";
            Process p = new Process();
            p.StartInfo.FileName = "rundll32.exe";
            //Arguments
            p.StartInfo.Arguments = @"C:\WINDOWS\System32\shimgvw.dll,ImageView_Fullscreen " + Path;

            p.Start();
        }


You can change the value of the variable "Path" and it the picture will be opened in the image viewer.


Hope it helps


[ Happy Coding ]
 
Share this answer
 
v2

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