Click here to Skip to main content
15,909,530 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In D Folder files are stored with the name of course name.

In D folder list of files as follows
RM.html     (file)

I have one design page as follows
Course name       Dropdownlist (In dropdownlist all course will be displayed)
                           RM(Course)

Then i have one Button Show Button.

When i select the Course (RM). i want to display the RM file content details.

For that how can i do using c#.

Display files from folder using c#.
Posted
Updated 4-Dec-14 20:25pm
v2

you can get files in folder as below ( change the extension accordingly)
C#
string[] files = System.IO.Directory.GetFiles(path, "*.html");

if you neee to bind only the File name to dropdownlist, use Path.GetFileNameWithoutExtension Method[^] example :
C#
string filenameNoExtension = Path.GetFileNameWithoutExtension(path);

on dropdownlist selected index changed event, you can read the file and display the content.you can use
File.ReadAllText[^]
C#
string html = File.ReadAllText(filepath);
webBrowser1.DocumentText = html;
//display the html in webBrowser control
 
Share this answer
 
v2
If it's HTML as the extension implies, just drop a WebBrowser control on your form, and then
myWebBrowser.Url = new Uri(@"file:///D:\myFolder\RM.html");

Should do it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900