How to get files from directory on the server map path ?
GetFilesFromDirectory(MapPath("~/temp/"));
private void GetFilesFromDirectory(string DirPath)
{
try
{
int id = 0;
DirectoryInfo Dir = new DirectoryInfo(DirPath);
FileInfo[] FileList = Dir.GetFiles("*.*");
dsFiles = comfunc.GetAllUserDetails(Convert.ToInt32(Request.QueryString["id"].ToString()), "SFILE");
if (dsFiles.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < dsFiles.Tables[0].Rows.Count; i++)
{
foreach (FileInfo FI in FileList)
{
if (dsFiles.Tables[0].Rows[i]["fname"].ToString() == FI.FullName)
{
FI.Delete();
}
id++;
//
}
}
}
FillClientDetails();
}
catch (Exception ex)
{
}
}
No comments:
Post a Comment