Hey there everyone,

I need to write a small program to get a certain task done, but I have zero experience in manipulating text files.

Can someone please give me a start on how to write the following program:

The program should take all the text files in a folder, and add the data in a csv text file, with columns:

Text file Name, Content of text file

Easy as that. I'm sure this cannot be that hard, please give me a start on this.

Thanks!

>Merging multiple text files into one csv text file

System.IO.File.AppendAllText("common.txt", System.IO.File.ReadAllText("file1.txt"))
System.IO.File.AppendAllText("common.txt", System.IO.File.ReadAllText("file2.txt"))
....

Interesting thanks, the will definitely help me. Any idea how I can get all of the filenames in a directory and put them in an array?

>how I can get all of the filenames in a directory and put them in an array?

Dim files() as String = System.IO.Directory.GetFiles("c:\path_here")

Ok, I'm going out of my mind at the moment. I have tried to remove all unwanted characters for the past four hours but nothing is working for me.

I want to remove ALL unwanted characters from a string, only the spaces between the words and the punctuation should remain, that is remove all enters and other garbage that keep messing up my data.

Any idea how I can do this?

I think you have to start a new thread for new question. Please mark this thread as solved if you have found an answer to your question.

I found a way to do it:

Dim NewStr As String
        Dim l As Long
        For l = 1 To Len(OldStr)
            If Asc(Mid(OldStr, l, 1)) > 31 Then
                NewStr = NewStr & Mid(OldStr, l, 1)
            End If
        Next
        PurgeString = NewStr

        Return PurgeString

It can be done fast in data merging software tools - EasyMorph, for example.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.