// Add namespace
using System.IO;
// listed files
// 1. for all files of directory folder
public void getfiles()
{
string targetDirectory = Server.MapPath("slider/images");
DirectoryInfo d = new
DirectoryInfo(targetDirectory);//get directory folder
FileInfo[] Files = d.GetFiles("*"); //get all files from Folder
string str = "";
foreach (FileInfo
file in Files)
{
str = str + "" + file.Name
+ ", ";
}
}
// 2. for selected extension files only of directory folder
public void getfiles()
{
string targetDirectory = Server.MapPath("slider/images");
DirectoryInfo d = new
DirectoryInfo(targetDirectory); //get directory folder
FileInfo[] Files = d.GetFiles("*.jpg");//get all files from Folder
string str = "";
foreach (FileInfo
file in Files)
{
str = str + "" + file.Name
+ ", ";
}
}
No comments:
Post a Comment