如何制作程序以访问服务器上的文件 [英] How to make a program to Access files on the server

查看:467
本文介绍了如何制作程序以访问服务器上的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想访问服务器上某个文件夹中的文件,并在Windows的窗体上显示它们.该怎么做?
例如:-我的服务器上有一个名为"Image"的文件夹,名为"localhost \ Deepak \ Image",并且该文件夹中现在有图像,我想以"form1"的形式显示所有图像.
请帮助.

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.

推荐答案

请参阅以下文章: ASP.NET用户控件:文件浏览器 [ ^ ]
See the following article : ASP.NET User Control: File Browser[^]


所以解决方案就在这里,就像这样:-



public void button1_Click(对象发送者,EventArgs e)
{
DialogResult ds = folderBrowserDialog1.ShowDialog();
如果(ds == DialogResult.OK)
{
string [] str = Directory.GetFiles(folderBrowserDialog1.SelectedPath);
foreach(str中的字符串fname)
{
if(fname.IndexOf(.jpg")> 0)
{
PictureBox img = new PictureBox();
img.Width = 200;
img.Height = 400;
img.Image = Image.FromFile(fname);
flowLayoutPanel1.Controls.Add(img);
}
}
}

}


现在将驱动器映射到服务器. :-)
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. :-)


这篇关于如何制作程序以访问服务器上的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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