Please could someone advise me how to display files in a particular directory on a website with the response.write command and not a datagrid
EG I will like to list just text.
Thanks
Grantusing System;
using System.Collections;
using System.Drawing;
using System.IO;
namespace FileDisplay
{
private class MyClass
{
public static void DisplayFiles(string directory)
{
DirectoryInfo dir = new DirectoryInfo(directory);
if (!dir.Exists)
throw new DirectoryNotFoundException();
foreach (FileInfo file in dir.GetFiles("*.*"))
{
Response.Write(file.FullName); //for just the filename, use file.Name
Response.Write("<br>");
}
}
}
}
0 comments:
Post a Comment