Click here to Skip to main content
15,912,329 members
Home / Discussions / C#
   

C#

 
QuestionMicrosoft.Office.Interop.Excel problem Pin
michaelgr116-Jun-09 3:07
michaelgr116-Jun-09 3:07 
AnswerRe: Microsoft.Office.Interop.Excel problem Pin
stancrm16-Jun-09 3:28
stancrm16-Jun-09 3:28 
GeneralRe: Microsoft.Office.Interop.Excel problem Pin
michaelgr116-Jun-09 4:36
michaelgr116-Jun-09 4:36 
GeneralRe: Microsoft.Office.Interop.Excel problem Pin
michaelgr116-Jun-09 6:58
michaelgr116-Jun-09 6:58 
GeneralRe: Microsoft.Office.Interop.Excel problem Pin
MumbleB16-Jun-09 7:55
MumbleB16-Jun-09 7:55 
GeneralRe: Microsoft.Office.Interop.Excel problem Pin
michaelgr117-Jun-09 6:45
michaelgr117-Jun-09 6:45 
QuestionInstalling fonts on a Vista Pc Pin
Okultist16-Jun-09 1:55
Okultist16-Jun-09 1:55 
AnswerRe: Installing fonts on a Vista Pc Pin
dan!sh 16-Jun-09 2:24
professional dan!sh 16-Jun-09 2:24 
GeneralRe: Installing fonts on a Vista Pc Pin
Luc Pattyn16-Jun-09 2:54
sitebuilderLuc Pattyn16-Jun-09 2:54 
GeneralRe: Installing fonts on a Vista Pc Pin
dan!sh 16-Jun-09 3:35
professional dan!sh 16-Jun-09 3:35 
GeneralRe: Installing fonts on a Vista Pc Pin
Okultist16-Jun-09 3:43
Okultist16-Jun-09 3:43 
GeneralRe: Installing fonts on a Vista Pc Pin
dan!sh 16-Jun-09 5:25
professional dan!sh 16-Jun-09 5:25 
GeneralRe: Installing fonts on a Vista Pc Pin
Okultist16-Jun-09 3:40
Okultist16-Jun-09 3:40 
AnswerRe: Installing fonts on a Vista Pc Pin
Okultist17-Jun-09 2:46
Okultist17-Jun-09 2:46 
QuestionState Maintenance Pin
ashajahanmca16-Jun-09 1:44
ashajahanmca16-Jun-09 1:44 
AnswerRe: State Maintenance Pin
Michael Bookatz16-Jun-09 1:50
Michael Bookatz16-Jun-09 1:50 
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 

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.