Load a datagridview using List<> with files in a folder

by ssi 11. November 2013 07:40
      private void LoadGridInFolder()
        {
          string  sMask = "*.*";
            string[] aExcludeExt = { ".DB",".JPG",".BMP",".PNG",".PDF",".TXT",".WMV",".MPEG",".AVI" };
            DirectoryInfo di = new DirectoryInfo(FullQualifiedDocumentFolder);
            List<PolicyDocs> DocRec = new List<PolicyDocs>();

            FileInfo[] DirFiles = di.GetFiles(sMask);
            foreach (FileInfo fi in DirFiles)
            {
                if (!aExcludeExt.Contains(fi.Extension.ToUpper()))
                {
                    PolicyDocs rcd = new PolicyDocs();
                    rcd.FileName = fi.Name;
                    rcd.Docdate = fi.LastAccessTime;
                    rcd.Length = fi.Length;
                    rcd.CreatedDate = fi.CreationTime;
                    rcd.Extension = fi.Extension;
                    rcd.Folder = di.Name;

                    DocRec.Add(rcd);
                }
            }
            dataGridView1.DataSource = DocRec;
            SetColumns(dataGridView1);

            // SetColumns(dataGridView1);
        }

Tags: , ,

CSharp

Add comment

biuquote
  • Comment
  • Preview
Loading

Calendar

<<  September 2025  >>
MoTuWeThFrSaSu
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

View posts in large calendar

RecentComments

None

Development Team @ Shelbysys

We develop custom database applications for our clients. Our development tool of choice is MS Visual Studio. 

Quotations

"A woman's guess is much more accurate than a man's certainty."
Rudyard Kipling