Click here to Skip to main content
15,923,222 members
Home / Discussions / C#
   

C#

 
GeneralRe: Parsing Line by line Pin
PIEBALDconsult17-Feb-09 15:21
mvePIEBALDconsult17-Feb-09 15:21 
Question[Message Deleted] Pin
wwwxyz17-Feb-09 10:08
wwwxyz17-Feb-09 10:08 
AnswerRe: how can I apply all txt files in the folder this code? Pin
DaveyM6917-Feb-09 10:19
professionalDaveyM6917-Feb-09 10:19 
General[Message Deleted] Pin
wwwxyz17-Feb-09 10:24
wwwxyz17-Feb-09 10:24 
GeneralRe: how can I apply all txt files in the folder this code? Pin
Calin Tatar17-Feb-09 10:36
Calin Tatar17-Feb-09 10:36 
General[Message Deleted] Pin
wwwxyz17-Feb-09 10:39
wwwxyz17-Feb-09 10:39 
GeneralRe: how can I apply all txt files in the folder this code? Pin
Calin Tatar17-Feb-09 10:56
Calin Tatar17-Feb-09 10:56 
GeneralRe: how can I apply all txt files in the folder this code? Pin
wwwxyz17-Feb-09 11:35
wwwxyz17-Feb-09 11:35 
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;

class MainClass
{
    public static void Main(string[] args)
    {
        string inFile, filePath;
        string line;
        //Console.WriteLine("Input file name to open!");
        //Console.WriteLine("Sample: d:\\filename.txt");
        //inFile = Convert.ToString(Console.ReadLine());
        foreach (string inFile in Directory.GetFiles(filePath))
        {
            StreamReader sr = File.OpenText(inFile);
            line = sr.ReadLine();
            Console.WriteLine();
            Console.WriteLine("Successful file open!...");
            Console.WriteLine();
            Console.WriteLine("Input file name to save!");
            Console.WriteLine("sample: d:\\filename.txt");
            filePath = Console.ReadLine();
            FileStream file = new FileStream(filePath, FileMode.Create);
            StreamWriter sw = new StreamWriter(file);
            List<string> lines = new List<string>();

            while ((line = sr.ReadLine()) != null)
            {
                lines.Add(line);
            }
            try
            {
                int numberOne = Int32.Parse(lines[0]);
                int numberTwo = Int32.Parse(lines[1]);
                int numberThree = Int32.Parse(lines[2]);
                int x = numberOne + numberTwo + numberThree;
                sw.WriteLine(x);
            }
            catch { }
            sw.Close();
            sr.Close();
        }

    }
}
        </string></string>


Error:
<br />
Error:<br />
A local variable named 'inFile' cannot be declared in this scope because it would give a different meaning to 'inFile', which is already used in a 'parent or current' scope to denote something else	<br />

GeneralRe: how can I apply all txt files in the folder this code? Pin
Calin Tatar17-Feb-09 11:40
Calin Tatar17-Feb-09 11:40 
GeneralRe: how can I apply all txt files in the folder this code? Pin
wwwxyz17-Feb-09 10:35
wwwxyz17-Feb-09 10:35 
AnswerRe: [Message Deleted] Pin
wwwxyz18-Feb-09 12:01
wwwxyz18-Feb-09 12:01 
QuestionDatagridview Columns modifier Pin
Priya Prk17-Feb-09 8:53
Priya Prk17-Feb-09 8:53 
AnswerRe: Datagridview Columns modifier Pin
Calin Tatar17-Feb-09 9:14
Calin Tatar17-Feb-09 9:14 
QuestionSharepoint Development - Where to Start? Pin
rkajal17-Feb-09 6:05
rkajal17-Feb-09 6:05 
AnswerRe: Sharepoint Development - Where to Start? Pin
ToddHileHoffer17-Feb-09 6:26
ToddHileHoffer17-Feb-09 6:26 
GeneralRe: Sharepoint Development - Where to Start? Pin
rkajal17-Feb-09 6:40
rkajal17-Feb-09 6:40 
GeneralRe: Sharepoint Development - Where to Start? Pin
ToddHileHoffer17-Feb-09 6:58
ToddHileHoffer17-Feb-09 6:58 
GeneralRe: Sharepoint Development - Where to Start? Pin
led mike17-Feb-09 7:08
led mike17-Feb-09 7:08 
GeneralRe: Sharepoint Development - Where to Start? Pin
rkajal17-Feb-09 10:11
rkajal17-Feb-09 10:11 
GeneralRe: Sharepoint Development - Where to Start? Pin
led mike17-Feb-09 11:04
led mike17-Feb-09 11:04 
GeneralRe: Sharepoint Development - Where to Start? Pin
rkajal17-Feb-09 10:13
rkajal17-Feb-09 10:13 
QuestionDllImport Pin
Alessio Granzotto17-Feb-09 5:44
Alessio Granzotto17-Feb-09 5:44 
AnswerRe: DllImport Pin
Luc Pattyn17-Feb-09 6:16
sitebuilderLuc Pattyn17-Feb-09 6:16 
GeneralRe: DllImport Pin
Alessio Granzotto17-Feb-09 6:30
Alessio Granzotto17-Feb-09 6:30 
GeneralRe: DllImport Pin
Mirko198018-Feb-09 3:32
Mirko198018-Feb-09 3:32 

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.