Welcome Guest Search | Active Topics | Sign In | Register

File Explorer filtering hidden files Options
hunpirate
Posted: Wednesday, October 7, 2020 8:46:45 AM
Rank: Advanced Member
Groups: Member

Joined: 6/14/2007
Posts: 83
Hi,

Can I get a little help on how to exclude hidden folders and files from File Explorer?


Thanks

Steve Komaromi

Computer Systems Manager, Lead Developer
Business Risk Partners, Inc.
Tel: 1-(860)-903-0039
eo_support
Posted: Wednesday, October 7, 2020 11:48:32 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

There is no built-in support for this. The following code provides a "hack" for you to achieve this:

Code: C#
private EO.Web.Grid m_Grid;

protected void Page_Load(object sender, EventArgs e)
{
    m_Grid = (EO.Web.Grid)FileExplorer1.FindControl("FileGrid");
    m_Grid.ColumnSort += Grid_ColumnSort;
}

protected override void OnPreRenderComplete(EventArgs e)
{
    base.OnPreRenderComplete(e);

    if (!IsPostBack)
        FilterGrid();
}

private void Grid_ColumnSort(object sender, EO.Web.GridColumnEventArgs e)
{
    FilterGrid();
}

private void FilterGrid()
{
    IList dataSource = (IList)m_Grid.DataSource;
    ArrayList filteredDataSource = new ArrayList();
    for (int i = 0; i < dataSource.Count; i++)
    {
        //Get the data source item and its full path
        object dataItem = dataSource[i];
        string[] pathInfo = dataItem.GetType().GetProperty("PathInfo").GetValue(dataItem, new object[] { }).ToString().Split('|');
        string fullPath = Server.MapPath(pathInfo[0]);

        //If the file does not have Hidden attribute,
        //then add it to filteredDataSource
        System.IO.FileInfo fileInfo = new System.IO.FileInfo(fullPath);
        if (((int)fileInfo.Attributes & (int)System.IO.FileAttributes.Hidden) == 0)
            filteredDataSource.Add(dataItem);
    }

    //Repopulate the Grid with the filteredDataSource
    m_Grid.DataSource = filteredDataSource;
    m_Grid.DataBind();
}


The basic idea is to let the Grid to populate all file item first, then examine each item and repopulate it with items you do not want removed. Please let us know if you have questions about the code.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.