Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # // Clear any existing list contents
- # blFiles.Items.Clear();
- #
- # // Physical path name of the folder/directory we're interested in
- # string pn = Server.MapPath("~/Docs/examples");
- #
- # // Build the virtual path, done step-by-step to show you how it's done
- # // (you would probably combine some of the steps in your code)
- # // Virtual path name of this web application's root
- # string pathToWebAppRoot = Request.ApplicationPath;
- # // Path to the above folder, relative to this web app's root
- # string pathToFolder = "/Docs/examples/";
- # // Complete path to the above folder
- # string urlPath = pathToWebAppRoot + pathToFolder;
- #
- # try
- # {
- # // Now we're going to get the list of files and place the list into an array
- # String[] fileList = Directory.GetFiles(pn);
- #
- # // Next, we'll loop through the array's contents, and
- # // assign the file name to the bullet's visible text property,
- # // and the urlpath + file name to the value property
- # // The BulletedList control's DisplayMode property was set to HyperLink
- # for (int i = 0; i < fileList.Length ; i++)
- # {
- # // Create a new list item
- # ListItem li = new ListItem();
- # // Set its text property to the file name
- # li.Text = Path.GetFileName(fileList[i]);
- # // Set its value property to a URL
- # li.Value = urlPath + li.Text;
- # // Add the item to the bulleted list
- # blFiles.Items.Add(li);
- # }
- # // for (int i = 0; i < fileList.Length; i++)
- # }
- # catch (Exception ex)
- # {
- # blFiles.Items.Add("There was an error while creating this list:");
- # blFiles.Items.Add(ex.Message);
- # }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement