473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to create new files from a text file ???

55
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

------------------------------------------------------------------------------------------------------------
Aug 15 '07 #1
0 1111

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Michael Sperlle | last post by:
Is it possible? Bestcrypt can supposedly be set up on linux, but it seems to need changes to the kernel before it can be installed, and I have no intention of going through whatever hell that would...
8
by: barb | last post by:
So that the world at large benefits from our efforts, here is one fully documented way to use Windows Irfanview freeware to create thumbnail web galleries (http://www.irfanview.com). STEP 1:...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
1
by: niveknornev | last post by:
Anyone ever used a script to create RDP session files? You can edit an RDP file using any text editor, however if you try to use simple batch, or vbscript to append text to that file, it doesn't...
15
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.