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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:43:37+00:00 2026-05-27T22:43:37+00:00

I’ve got an xml configuration file with the following file formats: <FILE FILEFORMAT=|PREFIX|DATETIME|-|STRING|NUMBER|_|DATETIME2|-|TIME|SUFFIX| />

  • 0

I’ve got an xml configuration file with the following file formats:

 <FILE FILEFORMAT="|PREFIX|DATETIME|-|STRING|NUMBER|_|DATETIME2|-|TIME|SUFFIX|" />
 <FILE FILEFORMAT="|PREFIX|NUMBER|_|DATETIME|-|TIME|SUFFIX|" />
 <FILE FILEFORMAT="|DATETIME|_|PREFIX|_|STRING|_|DATETIME2|-|TIME|SUFFIX|" />
 <FILE FILEFORMAT="|PREFIX|_|STRING|_|STRING2|_|DATETIME|_|DATETIME2|-|TIME|SUFFIX|"/>

where prefix is only alphabet, datetime/datetime2 is just numbers, not the actual datetime type(I will convert that into datetime later on), string is another alphabet, number is 0 to 9 numbers, time is digits also, suffix is the format of the file like .xml or .txt.

Examples of actual files:

`SUXX20111101-BATCH2240_20111113-091322.txt`
`TOBEME826908_20111113-091413.txt`
`2011-12-01_MYSELF_ANDI_20111208-121517.txt`
`WELL_MAYBENOT_TRUE_092011_20111215-022931.txt`

What I have to accomplish is to check weather the file name is according to specified format or not, there are multiple clients with different formats, I don’t know how to go and solve this puzzle, any help is greatly appreciated. basically the idea is not to touch the programming side if more files come in the future, adding their info to config file should suffice.

  • 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-27T22:43:38+00:00Added an answer on May 27, 2026 at 10:43 pm

    I’m not sure of what exactly you need, however if it’s a way to describe your filename pattern, you should simply use Regular Expression.

    Then you just have to loop among all formats.

    Here is a sample of how to do the search (assuming you have loaded your xml formats in formats, your searching directory in dir)

    Dictionary<string, Regex> formatDic = new Dictionary<string, Regex>();
    foreach(XElement curFormat in formats)
    {
         formats.Add(
             curFomat.Attribute("NAME"), 
             new Regex(curFomat.Attribute("FILEFORMAT"), RegexOptions.Compiled));
    }
    
    foreach(FileInfo curFile in dir.GetFiles())
    {
        try
        {
        Console.WriteLine(
            "File : {0} is of type : {1}",
            curFile.FullName,
            (from c in formatDic
             where c.Value.IsMatch(curFile.FullName)
             select c.Key).Single());
        }
        catch
        {
            Console.WriteLine("Error occuring on file : {0}", curFile.FullName);
        }
    }
    

    For more information on regexp : Regular expression on MSDN

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

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
i got an object with contents of html markup in it, for example: string
I'm parsing an XML file, the creators of it stuck in a bunch social
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

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.