从桌面选择图像而不进行浏览 [英] Select image from desktop without browsing

查看:57
本文介绍了从桌面选择图像而不进行浏览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用c#中的 Windows窗体应用程序。我可以通过使用

 OpenFileDialog()

从桌面浏览来上传我的表单中的图像,但我想通过单击直接从桌面的特定路径将图像上传到我的表单在一个按钮上。你能告诉我怎么做吗。



我尝试过:



现在我可以通过浏览使用OpenFileDialog();

解决方案

上传图片只需提供文件的路径:

< pre lang =c#> Image myImage = Image.FromFile( @ D:\Temp \ MyPic.jpg );



但是如果你不知道它,或者你没有将它存储在任何地方,你将不得不要求用户找到它...


I am working on a windows form application in c#. I can upload image in my form by browsing from desktop using

OpenFileDialog() 

but i want to upload image to my form directly from a specific path of my desktop directly by clicking on a button. Would you please tell me how to do that.

What I have tried:

now i can upload image by browsing using OpenFileDialog();

解决方案

Just supply the path to the file:

Image myImage = Image.FromFile(@"D:\Temp\MyPic.jpg");


But if you don't know it, or you haven't stored it anywhere, you will have to ask the user to locate it...


这篇关于从桌面选择图像而不进行浏览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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