简体   繁体   中英

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.

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM