I have just started my career in programming. My Problem is reading a
text file using VB.NET. The text contains the state names followed by respective city names. My task is to read the file and generate an
html page for each state with ciites.
File format is as follows:
Andhra Pradesh
Hyderabad
Warangal
Adilabad
kkk
ddd
ddd
Orissa
Bhubhaneshwar
kddk
dkdkd
ddkd
dkdkd
Maharashtra
Pune
Mumbai
Aurangabad
---
-----
-------
the file goes on with many state names and cites.
I have managed way to read and generate the html files but it works
if the text file contains information of only one state and city.
I dont know how to check the state name and generate file with
its respective city names. please help me in this regard.
i will be very thankful... the code which i used is as follows:
---------------------------------------------------------------------------------------------------------
Imports System.IO
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fs As New FileStream( "c:\states\statesncities.txt", FileMode.Open)
Dim sr As New StreamReader(fs, System.Text.Encoding.Unicode )
Dim line As String = ""
Dim sbu As New ArrayList
While Not sr.EndOfStream
sbu.Add(sr.ReadLine())
End While
fs.Close()
Dim fs2 As New FileStream( "c:\WebSite3\html_files\states\andhra_a.htm", FileMode.CreateNew)
Dim sw As New StreamWriter(fs2, System.Text.Encoding.Unicode )
Dim x As New StringBuilder()
x.Append("<select size=1 id=District size=1 OnChange=javascript:ZoomToState(); style=width: 160px; style=font-family: tahoma; font-size: 8pt >" )
x.AppendLine()
Dim counter As Integer
counter = 1
For Each line In sbu
x.Append(" <option Value=" & counter.ToString & ">" & line.ToString & "</option>")
x.AppendLine()
counter = counter + 1
Next
x.Append("</select>")
sw.Write(x.ToString)
sw.Flush()
sw.Close()
fs2.Close()
End Sub
------------------------------------------------------------------------------------------------------------