Click here to Skip to main content
15,916,835 members
Home / Discussions / C#
   

C#

 
QuestionReading Large Files Pin
MumbleB9-Jan-09 1:19
MumbleB9-Jan-09 1:19 
GeneralRe: Reading Large Files Pin
Luc Pattyn9-Jan-09 2:27
sitebuilderLuc Pattyn9-Jan-09 2:27 
GeneralRe: Reading Large Files Pin
MumbleB9-Jan-09 2:40
MumbleB9-Jan-09 2:40 
GeneralRe: Reading Large Files Pin
Luc Pattyn9-Jan-09 3:09
sitebuilderLuc Pattyn9-Jan-09 3:09 
GeneralRe: Reading Large Files Pin
musefan9-Jan-09 3:11
musefan9-Jan-09 3:11 
GeneralRe: Reading Large Files Pin
Ben Fair9-Jan-09 5:56
Ben Fair9-Jan-09 5:56 
GeneralRe: Reading Large Files Pin
MumbleB10-Jan-09 23:56
MumbleB10-Jan-09 23:56 
GeneralRe: Reading Large Files Pin
Ben Fair11-Jan-09 11:08
Ben Fair11-Jan-09 11:08 
Kwagga,

When you refer to values at offset 653 and 1134, are you referring to that offset in a particular line of text? In other words, do you need to read 11 characters starting from position 1134 when the character at position 653 in the line of text is 2, 4, 5, 6, 7, 8, or 9?

If so this would be how you do it (not sure if the offsets of 653 and 1134 are zero-based):

StreamWriter sw = ...;
StreamReader reader = null;
char flag = ' ';
try
{
    reader = new StreamReader(filePath);
    string holdLine = String.Empty;
    while(!reader.EndOfStream)
    {
        holdLine = reader.ReadLine();
        if(String.IsNullOrEmpty(holdLine))
            continue; // skip blank lines
        flag = holdLine[653]; // or offset 652?
        if(flag == '2' || flag == '4' || flag == '5' || flag == '6' ||
           flag == '7' || flag == '8' || flag == '9')
            sw.WriteLine(holdLine.Substring(1134, 11) + "\t" + flag.ToString()); // or offset 1133?
    }
}
catch(Exception ex)
{
    <... handle the exception here ...>
}
finally
{
    // be sure to close the reader and writer before exiting
    if(reader != null)
        reader.Close();
    if(sw != null)
        sw.Close();
}


In order to account for what you are trying to do and not have to hold the contents of the file in memory, in the FileHelper class one alternate would be for it to have an event that could, for example, be triggered each time a row is read from file. Then, you could handle the event and process each row as it comes in, utilizing the objects that the FileHelper class provides because the event could supply the IValueRev object via a custom EventArg. It seems that there are some objects the FileHelper class creates that probably interpret the data and make it easier to work with, so it has value for the system you are working within. Perhaps the best solution is not to abondon the tool if it indeed has a valuable capability, but to expand it to be more flexible.

Keep It Simple Stupid! (KISS)

QuestionPopulating ComboBox from ArrayList Pin
kanchoette8-Jan-09 23:07
kanchoette8-Jan-09 23:07 
AnswerRe: Populating ComboBox from ArrayList Pin
kanchoette8-Jan-09 23:32
kanchoette8-Jan-09 23:32 
QuestionDateTimePicker Pin
sandhya148-Jan-09 22:51
sandhya148-Jan-09 22:51 
AnswerRe: DateTimePicker Pin
Kristian Sixhøj8-Jan-09 22:55
Kristian Sixhøj8-Jan-09 22:55 
GeneralRe: DateTimePicker Pin
sandhya149-Jan-09 0:31
sandhya149-Jan-09 0:31 
GeneralRe: DateTimePicker Pin
User 66589-Jan-09 1:05
User 66589-Jan-09 1:05 
AnswerRe: DateTimePicker Pin
J4amieC8-Jan-09 23:34
J4amieC8-Jan-09 23:34 
AnswerRe: DateTimePicker Pin
belzer9-Jan-09 4:53
belzer9-Jan-09 4:53 
QuestionAN OPERATION ON SOCKET CANNOT BE PERFORMED - ERROR MESSAGE !!! Pin
senthilnathan8-Jan-09 22:36
senthilnathan8-Jan-09 22:36 
AnswerRe: AN OPERATION ON SOCKET CANNOT BE PERFORMED - ERROR MESSAGE !!! Pin
Colin Angus Mackay8-Jan-09 23:01
Colin Angus Mackay8-Jan-09 23:01 
QuestionGetting substring from a line Pin
ipstefan8-Jan-09 21:02
ipstefan8-Jan-09 21:02 
AnswerRe: Getting substring from a line Pin
Jason C Bourne8-Jan-09 21:10
Jason C Bourne8-Jan-09 21:10 
GeneralRe: Getting substring from a line Pin
ipstefan8-Jan-09 21:23
ipstefan8-Jan-09 21:23 
GeneralRe: Getting substring from a line Pin
Kristian Sixhøj8-Jan-09 21:26
Kristian Sixhøj8-Jan-09 21:26 
GeneralRe: Getting substring from a line Pin
ipstefan8-Jan-09 21:36
ipstefan8-Jan-09 21:36 
GeneralRe: Getting substring from a line Pin
Kristian Sixhøj8-Jan-09 21:39
Kristian Sixhøj8-Jan-09 21:39 
AnswerRe: Getting substring from a line Pin
sourabhsorate9-Jan-09 22:51
sourabhsorate9-Jan-09 22:51 

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.