Click here to Skip to main content
15,888,251 members
Home / Discussions / C#
   

C#

 
AnswerRe: State Maintenance Pin
Henry Minute16-Jun-09 1:54
Henry Minute16-Jun-09 1:54 
AnswerRe: State Maintenance Pin
himanshu256116-Jun-09 2:01
himanshu256116-Jun-09 2:01 
GeneralRe: State Maintenance Pin
Henry Minute16-Jun-09 4:39
Henry Minute16-Jun-09 4:39 
Questionhow to access javascript using c# Pin
svt gdwl16-Jun-09 1:19
svt gdwl16-Jun-09 1:19 
Questionweb services Pin
harispa16-Jun-09 1:05
harispa16-Jun-09 1:05 
AnswerRe: web services Pin
Baran M16-Jun-09 1:23
Baran M16-Jun-09 1:23 
AnswerRe: web services Pin
Tom Deketelaere16-Jun-09 1:24
professionalTom Deketelaere16-Jun-09 1:24 
QuestionProblem with while loop and text file Pin
kallileo16-Jun-09 0:56
kallileo16-Jun-09 0:56 
I have 2 text files.

input1.txt:
560-005;CORFU_1B;560-005-011
560-005;CORFU_1E;560-005-012
560-005;CORFU_1Z;560-005-013
560-005;CORFU_1H;560-005-014
560-005;SENSE_2B;560-005-021

input2.txt
562-Z21;METAL-ANTHRACITE;562-121-000
562-Z21;METAL-9007;562-221-000
562-Z22;METAL-ANTHRACITE;562-122-000
562-Z22;METAL-9007;562-222-000

public void Conversion()
        {
            try
            {
                using (sr1 = new StreamReader("c:\\input1.txt"))
                {
                    using (sr2 = new StreamReader("c:\\input2.txt"))
                    {
                        file = new FileStream("c:\\output.txt", FileMode.Create, FileAccess.Write);
                        sw = new StreamWriter(file);
                        string line1;
                        string line2;

                        while ((line1 = sr1.ReadLine()) != null)
                        {
                            string[] temp1 = line1.Split(new char[] { ';' });

                            while ((line2 = sr2.ReadLine()) != null)
                            {
                                string[] temp2 = line2.Split(new char[] { ';' });

                                string final = temp1[0] + ";" + temp1[1] + ";" + temp1[2] + ";" + temp2[2] + ";" + temp1[2] + "-" + temp2[2];
                                sw.WriteLine(final);
                            }
                        }

                    }
                }
            }
            finally
            {
                sr1.Close();
                sr2.Close();
                sw.Close();
                file.Close();
            }
        }


I have created the above method to do some string management. The problem is that the outer while loops runs only for the first line in input1.txt and I don't know why. It's probably something simple but I can't find the solution.

Thanks...
AnswerRe: Problem with while loop and text file [modified] Pin
Luc Pattyn16-Jun-09 1:03
sitebuilderLuc Pattyn16-Jun-09 1:03 
GeneralRe: Problem with while loop and text file Pin
OriginalGriff16-Jun-09 1:11
mveOriginalGriff16-Jun-09 1:11 
GeneralRe: Problem with while loop and text file Pin
Le centriste16-Jun-09 2:18
Le centriste16-Jun-09 2:18 
GeneralRe: Problem with while loop and text file Pin
Luc Pattyn16-Jun-09 2:42
sitebuilderLuc Pattyn16-Jun-09 2:42 
GeneralRe: Problem with while loop and text file Pin
kallileo16-Jun-09 2:46
kallileo16-Jun-09 2:46 
QuestionMultiple user accessing single DB Pin
Hum Dum16-Jun-09 0:50
Hum Dum16-Jun-09 0:50 
AnswerRe: Multiple user accessing single DB Pin
Tom Deketelaere16-Jun-09 1:22
professionalTom Deketelaere16-Jun-09 1:22 
GeneralRe: Multiple user accessing single DB Pin
Hum Dum16-Jun-09 18:55
Hum Dum16-Jun-09 18:55 
GeneralRe: Multiple user accessing single DB Pin
Tom Deketelaere16-Jun-09 21:09
professionalTom Deketelaere16-Jun-09 21:09 
AnswerRe: Multiple user accessing single DB Pin
Nagy Vilmos16-Jun-09 2:35
professionalNagy Vilmos16-Jun-09 2:35 
GeneralRe: Multiple user accessing single DB Pin
Hum Dum16-Jun-09 18:58
Hum Dum16-Jun-09 18:58 
AnswerRe: Multiple user accessing single DB Pin
OriginalGriff16-Jun-09 4:40
mveOriginalGriff16-Jun-09 4:40 
Questioncontroling cells in TableLayoutPanel Pin
samy10016-Jun-09 0:43
samy10016-Jun-09 0:43 
AnswerRe: controling cells in TableLayoutPanel Pin
OriginalGriff16-Jun-09 1:05
mveOriginalGriff16-Jun-09 1:05 
QuestionRemote Desktop Connection Pin
singhdurgesh16-Jun-09 0:17
singhdurgesh16-Jun-09 0:17 
AnswerRe: Remote Desktop Connection [modified] Pin
Baran M16-Jun-09 1:38
Baran M16-Jun-09 1:38 
GeneralRe: Remote Desktop Connection Pin
singhdurgesh16-Jun-09 1:56
singhdurgesh16-Jun-09 1:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.