需要有关代码的帮助 [英] Need help with a code

查看:119
本文介绍了需要有关代码的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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





我想指定图像URI(C:\ Users \ Sony \Desktop\c.jpg)作为一个字符串变量。所以我必须在startInfo.Arguments中进行哪些更改。

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.

推荐答案





试试这个:

Hi,

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



希望这会有所帮助。



字符串用引号括起来,正如史蒂夫44推荐的那样。[/编辑]





如果你想在照片浏览器中打开照片,那么你可以试试这个:


Hope this helps.

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


If you want to open a photo in a photo viewer, then you can try this:

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.


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();
        }





您可以更改变量Path的值,并在图像查看器中打开图片。





希望有帮助





[快乐编码]



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 ]


这篇关于需要有关代码的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆