Click here to Skip to main content
16,020,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on a windows form application in c#. I can upload image in my form by browsing from desktop using
C#
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();
Posted
Updated 11-May-16 23:09pm

1 solution

Just supply the path to the file:
C#
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...
 
Share this answer
 
Comments
Member 11345334 12-May-16 5:18am    
Thanks it's working @OriginalGriff
OriginalGriff 12-May-16 5:28am    
You're welcome!
Member 11345334 12-May-16 6:03am    
Is there any way to move my image from a specific path of my desktop to my localhost server?
OriginalGriff 12-May-16 6:11am    
Sorry? Remember that I have no idea what you are doing unless you type it in - so I have no context for what exactly you are trying to do.
Try explaining in more detail, please!
Member 11345334 12-May-16 6:20am    
I have an image in a specific directory such as D:\Temp\MyPic.jpg of my desktop. Now i want to copy it in my localhost server. How can i do that?

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