Ejemplo n.º 1
0
        private void PopulateFoldersAndFiles()
        {
            lblCurrentFolder.Text = Server.MapPath(this.CurrentFolder);
            // Get the list of files & folders in the CurrentFolder
            var currentDirInfo = new DirectoryInfo(GetFullyQualifiedFolderPath(this.CurrentFolder));
            var folders = currentDirInfo.GetDirectories();
            var files = currentDirInfo.GetFiles();

            var fsItems = new List<FileSystemItem>(folders.Length + files.Length);

            // Add the ".." option, if needed
            if (!TwoFoldersAreEquivalent(currentDirInfo.FullName, GetFullyQualifiedFolderPath(Common.DataDir)))
            {
                var parentFolder = new FileSystemItem(currentDirInfo.Parent);
                parentFolder.Name = "..";
                fsItems.Add(parentFolder);
            }

            foreach (var folder in folders)
                fsItems.Add(new FileSystemItem(folder));

            foreach (var file in files)
                fsItems.Add(new FileSystemItem(file));

            GridView1.DataSource = fsItems;
            GridView1.DataBind();
        }