protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string        appPath = Request.PhysicalApplicationPath;
            DirectoryInfo dirInfo = new DirectoryInfo(appPath);

            FileInfo[] files = dirInfo.GetFiles();
            FilesGrid.DataSource = files;



            string userName = User.Identity.Name;
            if (string.Compare(userName, "shem", true) == 0)
            {
                FilesGrid.Columns[1].Visible = true;
            }
            else
            {
                FilesGrid.Columns[1].Visible = false;
            }



            FilesGrid.DataBind();
        }
    }
示例#2
0
        protected void loadTeacherFileGrid()
        {
            string[]        filePaths = Directory.GetFiles(Server.MapPath("~/Uploads"));
            List <ListItem> files     = new List <ListItem>();

            foreach (string filePath in filePaths)
            {
                files.Add(new ListItem(Path.GetFileName(filePath), filePath));
            }
            FilesGrid.DataSource = files;
            FilesGrid.DataBind();
        }