Click here to Skip to main content
14,738,115 members
Home » Discussions » C#
   

C#

 
AnswerRe: State Maintenance Pin
Henry Minute16-Jun-09 2:54
MemberHenry Minute16-Jun-09 2:54 
AnswerRe: State Maintenance Pin
himanshu256116-Jun-09 3:01
Memberhimanshu256116-Jun-09 3:01 
GeneralRe: State Maintenance Pin
Henry Minute16-Jun-09 5:39
MemberHenry Minute16-Jun-09 5:39 
Questionhow to access javascript using c# Pin
svt gdwl16-Jun-09 2:19
Membersvt gdwl16-Jun-09 2:19 
Questionweb services Pin
harispa16-Jun-09 2:05
Memberharispa16-Jun-09 2:05 
AnswerRe: web services Pin
Baran M16-Jun-09 2:23
MemberBaran M16-Jun-09 2:23 
AnswerRe: web services Pin
Tom Deketelaere16-Jun-09 2:24
professionalTom Deketelaere16-Jun-09 2:24 
QuestionProblem with while loop and text file Pin
kallileo16-Jun-09 1:56
Memberkallileo16-Jun-09 1: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 2:03
sitebuilderLuc Pattyn16-Jun-09 2:03 
GeneralRe: Problem with while loop and text file Pin
OriginalGriff16-Jun-09 2:11
mveOriginalGriff16-Jun-09 2:11 
GeneralRe: Problem with while loop and text file Pin
Le centriste16-Jun-09 3:18
MemberLe centriste16-Jun-09 3:18 
GeneralRe: Problem with while loop and text file Pin
Luc Pattyn16-Jun-09 3:42
sitebuilderLuc Pattyn16-Jun-09 3:42 
GeneralRe: Problem with while loop and text file Pin
kallileo16-Jun-09 3:46
Memberkallileo16-Jun-09 3:46 
QuestionMultiple user accessing single DB Pin
Hum Dum16-Jun-09 1:50
MemberHum Dum16-Jun-09 1:50 
AnswerRe: Multiple user accessing single DB Pin
Tom Deketelaere16-Jun-09 2:22
professionalTom Deketelaere16-Jun-09 2:22 
GeneralRe: Multiple user accessing single DB Pin
Hum Dum16-Jun-09 19:55
MemberHum Dum16-Jun-09 19:55 
GeneralRe: Multiple user accessing single DB Pin
Tom Deketelaere16-Jun-09 22:09
professionalTom Deketelaere16-Jun-09 22:09 
AnswerRe: Multiple user accessing single DB Pin
Nagy Vilmos16-Jun-09 3:35
professionalNagy Vilmos16-Jun-09 3:35 
GeneralRe: Multiple user accessing single DB Pin
Hum Dum16-Jun-09 19:58
MemberHum Dum16-Jun-09 19:58 
AnswerRe: Multiple user accessing single DB Pin
OriginalGriff16-Jun-09 5:40
mveOriginalGriff16-Jun-09 5:40 
Questioncontroling cells in TableLayoutPanel Pin
samy10016-Jun-09 1:43
Membersamy10016-Jun-09 1:43 
AnswerRe: controling cells in TableLayoutPanel Pin
OriginalGriff16-Jun-09 2:05
mveOriginalGriff16-Jun-09 2:05 
QuestionRemote Desktop Connection Pin
singhdurgesh16-Jun-09 1:17
Membersinghdurgesh16-Jun-09 1:17 
AnswerRe: Remote Desktop Connection [modified] Pin
Baran M16-Jun-09 2:38
MemberBaran M16-Jun-09 2:38 
GeneralRe: Remote Desktop Connection Pin
singhdurgesh16-Jun-09 2:56
Membersinghdurgesh16-Jun-09 2: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.