John Snow
John Snow

Reputation: 1

Reading multiple Text files

Just a question, I'am using c# mvc for a project and I have this requirement of getting several text files from a particular path (network path to be precised - eg: \10.0.0.1\SharedFolder). Now, each text files has different text formats and what I have to do is to get any existing files from that path folder and create a single text file for all the text files.

  1. Is it possible to used a network path (the path was specified through user input) using a web application to access files?
  2. If yes, what would you suggest?

I was already looking at the option of using "Browse Folder" button, however, I wasn't getting any progress on how to achieve this.

Thanks in advance.

Upvotes: 0

Views: 496

Answers (2)

Hao
Hao

Reputation: 131

Yeah you can,

using (TextWriter writer = File.CreateText("C:\\Output.txt"))
{

//WRITE WHATEVER YOU WANT TO WRITE.

}

Just replace "C:\Output.txt" with the directory you want.

Hope this helps

Upvotes: 0

Hao
Hao

Reputation: 131

This is how I would do it =>

Iterate through each file in the directory using the .net Directory class.

For each file: Use the Textreaderclass to read each line Use the Textwriter class to write each line to your designated file

Let me know if you still can't figure it out!

Upvotes: 1

Related Questions