.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> General >> Post New Resource Bookmark and Share   

 Subscribe to Articles

HTML Image Gallery Builder in VB.NET

Posted By:Hefin Dsouza       Posted Date: August 14, 2009    Points: 25    Category: General    URL: http://www.dotnetspark.com  
 

This is a Simple Application Which can be used to Generate an HTML Gallery Quickly By Just Selecting an Image Folder.

It Automatically Gets The Images in a CheckListBox By Just Selecting an Image Folder

TextBox1.Text = FolderBrowserDialog1.SelectedPath

Dim imageFolder As New DirectoryInfo(TextBox1.Text)
Dim imageFiles() As FileInfo = imageFolder.GetFiles("*.jpg")
For Each f As FileInfo In imageFiles
Dim s = f.FullName.Remove(0, f.FullName.LastIndexOf("\") + 1)
CheckedListBox1.Items.Add(s)
Next
Copy's Selected Images To A New Folder

Directory.CreateDirectory(TextBox2.Text & "\Gallery_Images")
For i As Integer = 0 To CheckedListBox1.CheckedItems.Count - 1
File.Copy(TextBox1.Text & "\" & CheckedListBox1.CheckedItems(i), TextBox2.Text & "\Gallery_Images\" & CheckedListBox1.CheckedItems(i), True)
Next
Generates The HTML File

Dim gal As New StreamWriter(TextBox2.Text + "\index.html")
gal.WriteLine("< html >< head >< title >" & txtTitle.Text & "")
gal.WriteLine("< h1 >" & txtTitle.Text & "< /h1 >")
gal.WriteLine("< table border=1 >< tr >")
For i As Integer = 0 To CheckedListBox1.CheckedItems.Count - 1
gal.WriteLine("< td >< img width=" & txtWid.Text & " height=" & txtHeight.Text & " src='Gallery_Images\" & CheckedListBox1.CheckedItems(i) & "' / >< /td >")
Next
gal.WriteLine("< /tr >< /table >")
gal.Close()
Process.Start(TextBox2.Text + "\index.html")
You Can Freely Use the Codes and Improve this Application But Rememember to Give a Credit To Me.
For Complete Sample Download Attachment
Regards Hefin Dsouza
 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend