Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string alphaFilePath = @"C:\Users\trainee\Documents\visual studio 2010\Projects\ConsoleApplication3\ConsoleApplication3\bin\Debug\input.txt";

            List<string> alphaFileContent = new List<string>();

            using (FileStream fs = new FileStream(alphaFilePath, FileMode.Open))
            using (StreamReader rdr = new StreamReader(fs))
            {
                while (!rdr.EndOfStream)
                {
                    alphaFileContent.Add(rdr.ReadLine());
                }
            }

            string betaFilePath = @"C:\Users\trainee\Documents\visual studio 2010\Projects\ConsoleApplication3\ConsoleApplication3\bin\Debug\check.csv";

            StringBuilder sb = new StringBuilder();


            using (FileStream fs = new FileStream(betaFilePath, FileMode.Open))
            using (StreamReader rdr = new StreamReader(fs))
            {
                while (!rdr.EndOfStream)
                {
                    string[] betaFileLine = rdr.ReadLine().Split(Convert.ToChar(","));

                    if (alphaFileContent.Contains(betaFileLine[0]))
                    {
                        sb.AppendLine(String.Format("{0}, {1}", betaFileLine[0], betaFileLine[1]));
                    }
                }


            }

            using (FileStream fs = new FileStream(@"C:\Users\trainee\Documents\visual studio 2010\Projects\ConsoleApplication3\ConsoleApplication3\bin\Debug\result.txt", FileMode.Create))
            using (StreamWriter writer = new StreamWriter(fs))
            {
                writer.Write(sb.ToString());
            }

            Console.WriteLine(sb.ToString());
        }


    }
}


Here I am reading the input from the first file.
Then I am having a csv format file to which I check for matching words from the input file and if found one I extract it and put it up in the third file and print it.

But I am not getting any errors or the output.
What should i do ?

Help required...
Posted
v4
Comments
Shanu2rick 26-Feb-13 4:43am    
Buddy, please be more specific about the problem?
Chris Reynolds (UK) 26-Feb-13 5:00am    
Put some break points in and break the problem down. Is the first part definitely populating your list correctly? Then single step through your matching code to see if the comparisons are what you expect. Some time spent learning how to use the debugger to set breakpoints and inspect variables will save you a lot of time and you'll find solutions faster than us doing a static analysis of your code.

1 solution

it may be because there is no condition met for the blocks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900