【发布时间】:2014-02-18 14:56:14
【问题描述】:
我正在尝试从网页中获取目录和子目录中的文件。我不知道这是否是我正在使用的正确想法。如果不能,请告诉我如何访问 apache 服务器上 IP 地址上的文件和文件夹。
下面的代码显示“不支持 URI 格式”。错误。
我不想使用本地目录,因为我必须从该地址访问文件(apache 服务器)
public static DataTable search_method(string searchkeyword)
{
string path = "http://192.168.2.10/mywebsite/";
DataTable Table = new DataTable();
Table.Columns.Add("AnchorText");
Table.Columns.Add("dt");
DataRow dr = null;
foreach (string file in Directory.GetFiles(path, "*.*", SearchOption.AllDirectories))
{
if (file.Contains(searchkeyword))
{
string AnchorText = Path.GetFileNameWithoutExtension(file);
DateTime dt = File.GetLastWriteTime(path);
dr = Table.NewRow();
dr[1] = AnchorText;
dr[2] = dt;
Table.Rows.Add(dr);
}
}
return Table;
}
【问题讨论】:
标签: c# asp.net networking filesystems