Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to access my files in a folder on the server and show them on a form in windows . How to do this?
For ex:- I have a folder named "Image" on my server as "localhost\Deepak\Image" and there are images in the folder now I want to show all the images on a form "form1".
Plz help.
Posted
Comments
Sergey Alexandrovich Kryukov 18-Dec-11 14:56pm    
What is "localhost"? Directory or URL? If this is URL, use '/', not '\'. :-)
--SA

See the following article : ASP.NET User Control: File Browser[^]
 
Share this answer
 
So the solution is here and it goes like:-



public void button1_Click(object sender, EventArgs e)
{
DialogResult ds = folderBrowserDialog1.ShowDialog();
if (ds == DialogResult.OK)
{
string[] str=Directory.GetFiles(folderBrowserDialog1.SelectedPath) ;
foreach (string fname in str)
{
if(fname.IndexOf(".jpg")>0)
{
PictureBox img=new PictureBox();
img.Width = 200;
img.Height = 400;
img.Image = Image.FromFile(fname);
flowLayoutPanel1.Controls.Add(img);
}
}
}

}


And now map your drive to the server. :-)
 
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