Tuesday, August 21, 2007

RETRIEVE FILES FROM DIRECTORY IN C#

RETRIEVE FILES FROM DIRECTORY IN C#


//string yourdirectory=Server.MapPath("yourfoldername");
string yourdirectory="C://";

string []dir=Directory.GetFiles(yourdirectory);

for (int i = 0; i < dir.Length; i++)
{

//get individual file names
string fileName = dir[i].Substring(dir[i].ToString().LastIndexOf("\\") +1);
string entirePath = dir[i].toString();
}

No comments: