Example #1
0
        protected void DirClick_Click(object sender, EventArgs e)
        {
            var userid = ECDHAES256s.AES.Sha256(User.Identity.Name);

            UserPath = "/Upload/Files/" + userid + "/";
            BrowserMulti.ActiveViewIndex = 0;
            var dirId = DirID.Text;

            try
            {
                dirId = Encoding.UTF8.GetString(Convert.FromBase64String(dirId));
            }
            catch
            {
                dirId = DirID.Text;
            }
            if (dirId == userid || dirId == User.Identity.Name)
            {
                UserPath = "/Upload/Files/" + userid + "/";
            }
            else
            {
                //find actual path
                try
                {
                    var split = dirId.Split(new string[] { "\\Upload" }, StringSplitOptions.None);
                    var tmp   = split.Last().Replace("\\", "/");
                    var bb    = 0;
                    UserPath = "/Upload" + tmp;
                }
                catch
                {
                }
            }
            //get files
            List <FileFolderInfo> filesAndFolders = new List <FileFolderInfo>();
            var directories = Directory.GetDirectories(Server.MapPath(UserPath));

            foreach (var dir in directories)
            {
                var tmp   = dir;
                var split = tmp.Split(new string[] { "\\" }, StringSplitOptions.None).ToList();
                var name  = split.Last();
                filesAndFolders.Add(new FileFolderInfo(new DirectoryInfo(dir)));
            }
            var files = Directory.GetFiles(Server.MapPath(UserPath));

            foreach (var file in files)
            {
                var a = new System.IO.FileInfo(file);
                filesAndFolders.Add(new FileFolderInfo(a));
            }
            BindingFileList ds = new BindingFileList();

            filesAndFolders.ForEach(i => { ds.Add(i); });
            UpdateView("icon", ds);
            Session["UserPath"] = UserPath;
        }
Example #2
0
        private BindingFileList GetFiles(string relativePath = null)
        {
            var userid = ECDHAES256s.AES.Sha256(User.Identity.Name);

            if (relativePath == null)
            {
                UserPath = "/Upload/Files/" + userid + "/";
            }
            else
            {
                UserPath            = relativePath;
                Upath               = UserPath;
                Session["UserPath"] = relativePath;
            }
            BrowserMulti.ActiveViewIndex = 0;

            //get files
            List <FileFolderInfo> filesAndFolders = new List <FileFolderInfo>();
            var directories = Directory.GetDirectories(Server.MapPath(UserPath));

            foreach (var dir in directories)
            {
                var tmp   = dir;
                var split = tmp.Split(new string[] { "\\" }, StringSplitOptions.None).ToList();
                var name  = split.Last();
                filesAndFolders.Add(new FileFolderInfo(new DirectoryInfo(dir)));
            }
            var files = Directory.GetFiles(Server.MapPath(UserPath));

            foreach (var file in files)
            {
                var a = new System.IO.FileInfo(file);
                filesAndFolders.Add(new FileFolderInfo(a));
            }
            BindingFileList ds = new BindingFileList();

            filesAndFolders.ForEach(i => { ds.Add(i); });
            Session["UserPath"] = UserPath;
            Session["Files"]    = ds;
            return(ds);
        }