Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7447187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:32:04+00:00 2026-05-29T12:32:04+00:00

I am trying use filehelpers class builder but I am kinda confused on what

  • 0

I am trying use filehelpersclass builder but I am kinda confused on what to do with it.

       var cb = new DelimitedClassBuilder("temp", ",") { IgnoreFirstLines = 0, IgnoreEmptyLines = true, Delimiter = ","  };
        var sr = new StreamReader(stream);
        var headerArray = sr.ReadLine().Split(',');
        foreach (var header in headerArray)
        {
            var fieldName = header.Replace("\"", "").Replace(" ", "");
            cb.AddField(fieldName, typeof(string));
        }

        var engine = new FileHelperEngine(cb.CreateRecordClass());
        var result = engine.ReadStream(sr);

The DelimitedClassBuilder takes in as it’s first parameter a “className’ and then “delimiter”

    //
    // Summary:
    //     Creates a new DelimitedClassBuilder.
    //
    // Parameters:
    //   className:
    //     The valid class name.
    //
    //   delimiter:
    //     The delimiter for that class.
    public DelimitedClassBuilder(string className, string delimiter);

I then go through the first row of the stream what contains the header what I will later on use as the fieldNames for this “class”.

The last line reads all the rest of the information and returns it as an object array[]. I see inside it they are of class “temp”.

Yet I don’t know how actually cast it to the class “temp”. Right now I don’t really know how to get at the data. I know I can’t just do something like

result[0].SomeFieldName as the fieldName could change from run to run. So this also makes me wonder why it makes a class in the first place if I going to have to do something like get it by index or something.

As you can see right now I am very confused.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T12:32:07+00:00Added an answer on May 29, 2026 at 12:32 pm

    The easiest way is demonstrated in the examples.

    You use

    DataTable dt = engine.ReadStreamAsDT(sr);
    

    and then access the results with something like:

    foreach (DataRow row in dt.Rows) // Loop over the rows.
    {
        Console.WriteLine("--- Row ---"); // Print separator.
        foreach (var item in row.ItemArray) // Loop over the columns.
        {
            Console.Write("Item: "); // Print label.
            Console.WriteLine(item); 
            /// the Type of item will be whatever you defined when you
            /// called ClassBuilder.AddField() (String in your example)
        }
    }
    Console.ReadLine();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying use a Java annotation in a Groovy class but have trouble to
I am using filehelpers 2.9.9 and trying to use FiledOptional but I keep getting
I'm trying use self-signed certificate (c#): X509Certificate2 cert = new X509Certificate2( Server.MapPath(~/App_Data/myhost.pfx), pass); on
I'm a little confused here, I am trying use a partial view in a
trying to use the preferred on method call but the code is not working
I was trying use svn to find a checkin using svn log, but it
I am trying use std::copy to copy from two different iterator. But during course
I'm trying use the Sum method in a lambda expression for a comparison, but
I am trying use the new server side plug-in feature for TFS 2010. (I
I am trying use cursor for pagination. Forwarding pagination work fine, but I can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.