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 6788171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:27:12+00:00 2026-05-26T17:27:12+00:00

I’ve wrote an app to iterate through a directory which contains x amount of

  • 0

I’ve wrote an app to iterate through a directory which contains x amount of files, and import each of them into objects within my program. I create an instance of a class for each of the files which are “payment”, and the FileHelpers library reads each line of the file as a new record – into a List. If the files are “info”, they are simply moved to preset directories. I am wanting to either append the name of the file to the end of the List or just include this as a variable?

I need to know the name of the file, as each of the “payments” within x amount of files are combined into one fixed width text file to load into our legacy housing management system.

MORE INFO:
When I create the fixed width file, I need to output each of the payments within the List<Payment> PLUS the name of the file they came from. I am unsure of how to do this
within FileHelpers/C# world 🙁

E.G. (headers for display purposes – not required in export file)

PAYMENTID PAYMENTAMOUNT REFERENCE DATE FILETYPE FILENAME
011102010 000000010000 20148366 26102011 PO SHGR1234.PO
011102011 000000020000 20148367 26102011 PP SHGF6585.PP
011102012 000000030000 20148368 26102011 DD SHGI9854.DD

Any ideas? Below are some code snippets…

UPDATE – FileHelpers lib = http://www.filehelpers.com/

UPDATE 2 – Code used to loop through text file and get payments

public List<SundryPayment> getOAPayments()
        {
            FileHelperEngine engine = new FileHelperEngine(typeof(SundryPayment));
            res = (SundryPayment[])engine.ReadFile(getFilePath());
            foreach (SundryPayment record in res)
            {
                OAPaymentsList.Add(record);
            }
            return OAPaymentsList;
        }

Update 2 – Code to load files

public List<object> getFiles()
        {
            List<object> obj = new List<object>();
            foreach (string file in files)
            {
                fileExt = Path.GetExtension(file).ToUpper();
                filePath = Path.GetFullPath(file).ToUpper();
                fileName = Path.GetFileNameWithoutExtension(file).ToUpper();
                fullFileName = Path.GetFileName(file).ToUpper();
                fileFund = fileName.Substring(0, 4).ToUpper();

                if (fileExt == ".DIR" || fileExt == ".ERR" || fileExt == ".CRF" || fileExt == ".STA")
                {
                    //Create Info File
                    InfoFile infofile = new InfoFile(filePath);
                    obj.Add(infofile);
                }
                else if (fileExt == ".PO" || fileExt == ".PP" || fileExt == ".TDC" || fileExt == ".TCC" || fileExt == ".DD" || fileExt == ".CSH" || fileExt == ".CQE"
                    || fileExt == ".PZ")
                {
                    if (fileFund == "SHGS" || fileFund == "GGEN")
                    {
                        //Create OA Payment File
                        OAPaymentFile oafile = new OAPaymentFile(filePath);
                        obj.Add(oafile);
                    }
                    else if (fileFund == "SHGF")
                    {
                        InfoFile infofile = new InfoFile(filePath);
                        obj.Add(infofile);
                    }
                    else
                    {
                        //Create AH Payment File
                        AHPaymentFile ahfile = new AHPaymentFile(filePath);
                        //Console.WriteLine("Object Created: {0}", filePath);
                        obj.Add(ahfile);
                    }
                }
            }

            return obj;


        }

Update 2 – (prototype) code used to create fixed width file. Need to put filename where paymetns came from into this file

public new void Create()
        {
            string fileToCreate = Path.Combine("\\\\san\\ict\\allpay\\test\\", "cash.txt");

            using (StreamWriter sw = new StreamWriter(fileToCreate))
            {
                foreach (Payment r in ArchousePayments)
                {
                    string archouseref = r.TenancyRef + r.SubAccount + r.CheckDigit;
                    string firstamount = r.AmountPaid.Replace(".", "");
                    string amount = firstamount.PadRight(10, 'x');
                    string transcode = "ALPY";
                    string date = r.PaymentDate.Substring(0, 2) + r.PaymentDate.Substring(3, 2) + r.PaymentDate.Substring(6, 4);
                    string siteref;
                    string comment;
                    sw.WriteLine(archouseref + amount + transcode + date + amount.Length);
                }

            }
        }
  • 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-26T17:27:13+00:00Added an answer on May 26, 2026 at 5:27 pm

    I figured this one one by adding another fixed width record to the end of my Import class, then used this to store the filename via Path.GetFileName(). I could then pass this into the class as required.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.