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.


7 Years
Discussion Span
Last Post by ALex_67

>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"))

Edited by __avd: n/a


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
        PurgeString = NewStr

        Return PurgeString

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.