3
Reply

listview to return filename and file owner

steve potts

steve potts

Aug 7 2012 5:13 AM
2.2k
I have a listview, and currently i return the filenames like this..

foreach (string file in files)
            {
                
                
                if (System.Text.RegularExpressions.Regex.IsMatch(file, sPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                {
                    listView1.Items.Add(file);
                    

                }

what i would like to do is also be able to retrive the file owner, which i think i can do with this code, but im not sure how to do it along side my existing code and get into the listview alongside the filename?
this gets the file owner i think..
System.IO.File.GetAccessControl(file).GetOwner(typeof(System.Security.Principal.NTAccount)).ToString();

thanks, steve.

Answers (3)