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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:23:05+00:00 2026-05-18T08:23:05+00:00

I have a console based application which pulls files from a database and outputs

  • 0

I have a console based application which pulls files from a database and outputs them onto the C drive. It also outputs an excel file with the details of all outputted files. Here is the snippet of code from the app.config file.

  <target name="Group1" acceptedFileTypes="pdf">
    <ftpSettings server="localhost" username="anonymous" password="user@user.com" />
    <metadataEncoder name="Group1" fileName="Group1_YYYYMMDD.xls" />
  </target>

Ideally, when the program runs, I would like the excel file to be named with the date appended onto the end of it. Is there any way I can achieve this in the app.config file?

Also, here is the class that relating to the above app.config snippet:

public class MetadataEncoderElement : ConfigurationElement
{
    private static readonly ConfigurationProperty messageName = new ConfigurationProperty("name", typeof(string), string.Empty, ConfigurationPropertyOptions.IsRequired);
    private static readonly ConfigurationProperty fileName = new ConfigurationProperty("fileName", typeof(string), string.Empty, ConfigurationPropertyOptions.IsRequired);

    public MetadataEncoderElement()
    {
        this.Properties.Add(messageName);
    }

    [ConfigurationProperty("name", IsRequired = true)]
    public string Name { get { return (string)this[messageName]; } }

    [ConfigurationProperty("fileName", IsRequired = true)]
    public string FileName { get { return (string)this[fileName]; } }
}

Any help would be appreciated, thanks guys.

EDIT

Have edited my code to the following

[ConfigurationProperty("fileName", IsRequired = true)]
public string FileName = string.Format(MetadataEncoderElement.fileName, DateTime.Now);

However now I have the following errors:

The best overloaded method match
for’string.Format(System.IFormatProvider,
string, params object[])’ has some
invalid arguments

Argument 1: cannot convert from’System.Configuration.ConfigurationProperty’
to ‘System.IFormatProvider’

Argument 2: cannot convert from ‘System.DateTime’ to ‘string’

  • 1 1 Answer
  • 2 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-18T08:23:05+00:00Added an answer on May 18, 2026 at 8:23 am

    Slightly improved version of Richards answer:

    <metadataEncoder name="Group1" fileName="Group1_{0:yyyyMMdd}.xls" />
    

    in the code

    string fileName = string.Format(yourconfig.FileName,DateTime.Now);
    

    EDIT:
    If you want to build it in your Property you can do it this way:

    [ConfigurationProperty("fileName", IsRequired = true)]
    public string FileName { get { return string.Format((string)this[fileName], DateTime.Now); } }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a console-based QCoreApplication which has timers and does socket communication and also
I have a fairly intensive application, which I've just converted from a console application
I have a console based MEF application the host ( CompositionContainer ) of which
I have a console application that should do best effort logging to a database
I have a console application which is parsing HTML documents via the WebRequest method
I want to code a VC++ 9 based console application which downloads an image
I have a VS 10 console application,which has to take two char inputs and
I have an application that allows administrators to specify valid IP addresses from which
I am preparing an application which is console based and the outcome of the
I have an application which posts progress/status messages as it runs (it's a database

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.