从远程服务器获取文件名 [英] get file name from remote server

查看:231
本文介绍了从远程服务器获取文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个服务器链接,例如:http://document.aaaa.com
在dat中,我创建了一个文件夹名称pdf,其中存储了100个pdf文件,其名称类似于
xyz_Q1,xyz_Q2 ...

通过前端,我将根据某些条件将值仅作为"xyz".
现在我想检索服务器名称xyz中的所有文件,例如输出将是xyz_Q1,xyz_Q2 ans,依此类推,然后单击该文件,然后从其他选项卡上的服务器中打开文件.

我无法通过代码与服务器映射.我已经在以下代码的帮助下完成了将文件夹保存在计算机上的操作:

DirectoryInfo dinfo = new DirectoryInfo(".. \\ Portals \\ PDFs");

i have a server link like: http://document.aaaa.com
in dat i hve create a folder name pdf where 100s pdfs are store with name like
xyz_Q1,xyz_Q2...

through front end i m taking the value depending on some conditions as only "xyz".
now i want to retreive all the files from server name xyz like the ouput will be xyz_Q1,xyz_Q2 ans so on and clicking on the file i want to open the file from server on different tab.

i m not able to map with server through code. this i hve done with the folder keeping on my computer with the help of following code:

DirectoryInfo dinfo = new DirectoryInfo("..\\Portals\\PDFs");

FileInfo[] finfo = dinfo.GetFiles(string.Format("{0}*.pdf", var));
            lstpdfs.Items.Clear();
            for (int i = 0; i < finfo.Length; i++)
            {

                list.Value = finfo[i].ToString();
                lstpdfs.Items.Add(list.Value);
            }



请提出一些使用远程URL进行上述操作的方法,例如当我在目录信息中传递url时,由于我们无法传递url而导致出现异常.我也尝试使用server.mappath来做,例如:

DirectoryInfo dinfo =新的DirectoryInfo(Server.MapPath("http://document.aaaa.com/foldername");

请建议如何解决



please suggest some way to do the above thing with the remote url as when i pass the url in the directory info i m getting the exception as we cant pass url. i also tried to do with server.mappath like:

DirectoryInfo dinfo = new DirectoryInfo(Server.MapPath("http://document.aaaa.com/foldername");

Please suggest how to solve

推荐答案

在客户端-服务器环境中,了解在何处运行哪个程序以及如何传达结果始终很重要.由于文件位于您通过http与之通信的服务器上,因此用于过滤的代码也应在该服务器上运行.这意味着必须将代码放置在在aspx页面中.
In a client-server environment, it is always important to know where to run which program and how to communicate the results. Since your files are on a server with which you communicate via http, the code for filtering ought to be run on the server, too. That means, the code must be placed e.g. in an aspx page.


这篇关于从远程服务器获取文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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