hi One and all,
I am trying to build web server for win Mo and i am trying to get the link of folders from certain directory so that it could be click able and could see all of the defined item (say - pictures from that folder..) i am being able to explore certain folders and items but how can i send my link towards html page or how to create a dynamic html page.... I have been in process doing this with little program in c# console mode.
my code is ....
.................................................. ...............................................
StringBuilder sb = new StringBuilder();
sb.AppendLine("<html>");
sb.AppendLine("<head>");
sb.AppendLine("<title>Index of c:\\tike</title>");
sb.AppendLine("</head>");
sb.AppendLine("<body>");
sb.AppendLine("<ul>");
string[] filePaths = Directory.GetFiles(@"c:\tike");
for (int i = 0; i < filePaths.Length; ++i)
{
string name = Path.GetFileName(filePaths[i]);
sb.AppendLine(string.Format("<li><a href=\"{0}\">{1}</a></li>",
HttpUtility.HtmlEncode(HttpUtility.UrlEncode(name) ),
HttpUtility.HtmlEncode(name)));
}
sb.AppendLine("</ul>");
sb.AppendLine("</body>");
sb.AppendLine("</html>");
string result = sb.ToString();
Console.WriteLine(result);
Console.Read();
.................................................. .................................................. ....
As result i see console mode as
<html>
<............>
<li><a href=...................................>
and all whatever i have appended
to sum up i wanted to make those things to run in html page...
any suggestion or snippet would be appreciated.
regards.
Tike
If you want to create dynamic pages using C# as the codebehind I would suggest using ASP.Net since it is really easy to implement exactly what you are talking about.
I agree. asp.net does what you're trying to do by hand. you need a way to map the urls to the file paths, and iis is a webserver that you can use to do that, and the code it uses is asp.net. I recommend taking a look at Imar Spaanjaars "Beginning ASP.NET 3.5". That's a good book if you're new to asp.net and programming. if you're a little more advanced at programming, you will skip some parts, but you'll learn how the basic things are done.
Last edited by Roger; 08-13-2010 at 03:01 PM.
"win Mo"? You mean Windows mobile? Guys, is there iis for windows mobile?
If you want to write a HTTP server from scratch, look into the Cassini web server:
Cassini Sample Web Server : The Official Microsoft ASP.NET Site
It comes with the C# source code and supports can run ASP.NET.
I'd start there. If you dont need ASP.NET, then remove it.
found article: Creating your own Web Server using C#
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks