/* ------------------------ My Meta Content Here SEO ------------------------ */

Pages

Main Menu

Tuesday, August 21, 2012

ASP.NET Getting files from directory


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

My Blog List

  • काश - काश मुझे भी पीने की आदत होती,मैं कब का मुर्दा हो गया होता। छुटकारा मिलता आज के आतंकवाद से, किसी संतान भूमि में सो गया होता। मेरा एतबार कौन करेगा, मैंने मुर...
    3 months ago
  • काश - काश मुझे भी पीने की आदत होती,मैं कब का मुर्दा हो गया होता। छुटकारा मिलता आज के आतंकवाद से, किसी शमशान भूमि में सो गया होता। मेरा एतबार कौन करेगा, मैंने मुर...
    3 months ago
  • Kumaon University Nainital B.Ed entrance exam test result 2012 - कुमाऊँ विश्वविधालय, नैनीताल (उत्तराखण्ड)
    10 years ago