private void SetFileList(DirectoryInfo di)
        {
            var files     = di.GetFiles();
            var the_Files = new List <FileInfo>();

            foreach (FileInfo fi in files)
            {
                if (FileFilters.IsValidFile(fi.Name))
                {
                    the_Files.Add(fi);
                }
            }

            if (the_Files.Count > 0)
            {
                the_Files.Sort(delegate(FileInfo f1, FileInfo f2) { return(Comparer <string> .Default.Compare(f1.Name, f2.Name)); });
                int half = the_Files.Count / 2 + the_Files.Count % 2;

                var left  = new List <AFile>();
                var right = new List <AFile>();

                for (int i = 0; i < the_Files.Count; i++)
                {
                    AFile af = new AFile();
                    af.Name    = the_Files[i].Name;
                    af.Path    = Request.QueryString["path"] ?? "";
                    af.OnClick = string.IsNullOrEmpty(OnClientFileClickedFunction)
                                                             ? ""
                                                             : "return select('" + GetJavaScriptUrl(the_Files[i].FullName) + "');";

                    if (i + 1 <= half)
                    {
                        left.Add(af);
                    }
                    else
                    {
                        right.Add(af);
                    }
                }

                LeftFiles.DataSource = left;
                LeftFiles.DataBind();

                RightFiles.DataSource = right;
                RightFiles.DataBind();
            }
        }
Example #2
0
        private void SetFileList(DirectoryInfo di)
        {
            FileInfo[] files = di.GetFiles();
            List<FileInfo> the_Files = new List<FileInfo>();

            foreach (FileInfo fi in files)
            {
                if (FileFilters.IsValidFile(fi.Name))
                    the_Files.Add(fi);
            }

            if (the_Files.Count > 0)
            {
                the_Files.Sort(delegate(FileInfo f1, FileInfo f2) { return Comparer<string>.Default.Compare(f1.Name, f2.Name); });
                int half = the_Files.Count / 2 + the_Files.Count % 2;

                List<AFile> left = new List<AFile>();
                List<AFile> right = new List<AFile>();

                for (int i = 0; i < the_Files.Count; i++)
                {
                    AFile af = new AFile();
                    af.Name = the_Files[i].Name;
                    af.Path = Request.QueryString["path"] ?? "";
                    af.OnClick = string.IsNullOrEmpty(this.OnClientFileClickedFunction) ? "" : "return select('" + GetJavaScriptUrl(the_Files[i].FullName) + "');";

                    if (i + 1 <= half)
                        left.Add(af);
                    else
                        right.Add(af);
                }

                LeftFiles.DataSource = left;
                LeftFiles.DataBind();

                RightFiles.DataSource = right;
                RightFiles.DataBind();
            }
        }