Hi ,
i want to load txt file that build from tow columns separator by 'tab' every column go to different list how can I do it ? how can I read until 'tab' and then continue from my last stop.
example to the file
one 1
tow 2
three 3

huh?

I'm gonna guess what the heck you mean here, and hand you an answer.

List<string> a = new List<string>();
            List<string> b = new List<string>();

            using ( StreamReader reader = new StreamReader(File.OpenRead(FILE_PATH)) ) {
                string line = null;
                string[ ] parts = null;

                try {
                    while ( (line = reader.ReadLine()) != null ) {
                        if ( String.IsNullOrEmpty(line) ) continue;

                        parts = line.Split(new char[ ] { '\t' }, StringSplitOptions.RemoveEmptyEntries);

                        if ( parts.Length >= 1 ) {
                            a.Add(parts[0]);

                            if ( parts.Length >= 2 ) {
                                b.Add(parts[1]);
                            }
                        }
                    }
                } catch ( Exception exception ) {
                    throw exception;
                } finally {
                    reader.Close();
                }
            }
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.