Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Create directory from text field

Status
Not open for further replies.

jerijeri

Programmer
Sep 11, 2002
33
CA
I need to create a large number (2500+) of directories on my computer.

I have a text field that will consist of rows of data like:

atlanta
los_angeles
detroit
new_york

I'm reading these in from a text file.

I'm trying to figure out the code that will read each line in the text field and create a directory based on each line. i.e. e:\files\atlanta , e:\files\los_angeles , e:\files\detroit , e:\files\new_york


If possible I'd also like it save a blank file called data.txt in the created directory.

Any help welcomed.

Thanks,

Jeri
 
mkDir "e:\files\" & text1.text

You may also want to check if directory exists.. can you do that?

Sunil
 
I'm afraid that's not working:


I have

Dim dirname variant

MkDir "e:\files\" & dirname & "\data.txt"

I get a path not found error. Which makes sense, since I'm trying to create the path.

There are two parts to the question. I need to:

1. figure out how to read each line in the text box
2. create the directory in my e:\files directory.

I'm a complete newbie to VB 6.

Thanks.

Jeri
 
Answering the parts..

First Part

Dim arr() As String
Dim i As Integer
arr = Split(Text1.Text, vbNewLine)

For i = 0 To UBound(arr)
Debug.Print arr(i)
Next


Second Part

Now, the MkDir command is for making a directory. Not a file. To create a file inside a new directory, first issue the MkDir to create the directory, and then create the file inside the folder with the file Open Statement..

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top