예제 #1
0
        public List <WsFile> GetFiles(string Path, int PageIndex, int PageSize, out int TotalRecord)
        {
            TotalRecord = 0;

            if (!this.IsValid())
            {
                return(null);
            }

            List <WsFile> listFile = new List <WsFile>();

            string[]  ArrFiles     = Directory.GetFiles(Server.MapPath("~/" + Path), "*.*");
            IComparer fileComparer = new CompareFileByDate();

            TotalRecord = ArrFiles.Length;

            Array.Sort(ArrFiles, fileComparer);

            for (int i = PageIndex * PageSize; i < PageSize * (PageIndex + 1) && i < ArrFiles.Length; i++)
            {
                string _PathFile = ArrFiles[i];

                FileInfo _FlieInfo = new FileInfo(_PathFile);

                string _FileName = System.IO.Path.GetFileName(_PathFile);
                //string _DirName = System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(_PathFile));

                WsFile file = new WsFile
                {
                    Name     = _FileName,
                    FullName = (Path == string.Empty ? string.Empty : Path + "/") + _FileName,
                    Length   = _FlieInfo.Length,
                    //Size = (float)((float)_FlieInfo.Length / (float)1024),
                    Modified = _FlieInfo.LastWriteTime
                };

                listFile.Add(file);
            }

            return(listFile);
        }
예제 #2
0
        public List<WsFile> GetFiles(string Path, int PageIndex, int PageSize, out int TotalRecord)
        {
            TotalRecord = 0;

            if (!this.IsValid())
                return null;

            List<WsFile> listFile = new List<WsFile>();

            string[] ArrFiles = Directory.GetFiles(Server.MapPath("~/" + Path), "*.*");
            IComparer fileComparer = new CompareFileByDate();

            TotalRecord = ArrFiles.Length;

            Array.Sort(ArrFiles, fileComparer);

            for (int i = PageIndex * PageSize; i < PageSize * (PageIndex + 1) && i < ArrFiles.Length; i++)
            {
                string _PathFile = ArrFiles[i];

                FileInfo _FlieInfo = new FileInfo(_PathFile);

                string _FileName = System.IO.Path.GetFileName(_PathFile);
                //string _DirName = System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(_PathFile));

                WsFile file = new WsFile
                {
                    Name = _FileName,
                    FullName = (Path == string.Empty ? string.Empty : Path + "/") + _FileName,
                    Length = _FlieInfo.Length,
                    //Size = (float)((float)_FlieInfo.Length / (float)1024),
                    Modified = _FlieInfo.LastWriteTime
                };

                listFile.Add(file);
            }

            return listFile;
        }