Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 20th, 2004, 02:14 PM
Registered User
 
Join Date: Feb 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Tom Perro
Default Folder listing and permissions

I have an aspx page that is displaying the contents of a directory on my web server. Each folder has different permissions based on user log ons. My problem is this. . .
I do not want to display folders in which users do not have permission to. Is there a way to do this?

Here is the code . . .
C#

public void Page_Load(object s, System.EventArgs ea) {
    try {
        string strDir = Request.QueryString["d"];
        string strParent = strDir.Substring(0,strDir.LastIndexOf("\\"));
        strParent += strParent.EndsWith(":") ? "\\" : "";
        upLink.NavigateUrl = "browse.aspx?d="+strParent;
        txtCurrentDir.Text = "Address: <b>"+strDir + "</b>";
        DirectoryInfo DirInfo = new DirectoryInfo(strDir);
        DirectoryInfo[] subDirs = DirInfo.GetDirectories();



        FileInfo[] Files = DirInfo.GetFiles();
        txtListing.Text = "<table>";
        for (int i=0; i<=subDirs.Length-1; i++) {

            txtListing.Text +="Check auth here";

            txtListing.Text += "<tr><td><img src='images/folder.gif'><a href='browse.aspx?d="+subDirs[i].FullName+"' class='entry'>"+subDirs[i].Name+"</a></td><td valign='bottom'>"+subDirs[i].LastWriteTime+"</td></tr>";
        }
        for (int i=0; i<=Files.Length-1; i++) {
            txtListing.Text += "<tr><td><img src='images/file.gif'>"+Files[i].Name+"</td><td valign='bottom'>"+Files[i].LastWriteTime+"</td></tr>";
        }
        txtListing.Text += "</table>";

    }

    catch (UnauthorizedAccessException ex){

    }


    catch (Exception e){

        txtListing.Text = "Error retrieving directory info: "+e;
    }
}

 
Old February 23rd, 2004, 10:59 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

Wrong forum..
Use this instead: http://p2p.wrox.com/forum.asp?FORUM_ID=56

Regards - Jon





Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting Folder Permissions lewdogg Classic ASP Components 0 June 28th, 2005 07:23 PM
Listing Folder Content jmss66 Classic ASP Basics 7 August 9th, 2004 11:40 AM
How to set permissions on a shared folder adman Pro VB 6 1 February 19th, 2004 11:07 AM
Set permissions on a shared folder adman Beginning VB 6 2 February 12th, 2004 03:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.