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

  • Home
  • SEARCH
  • 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 6585357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:39:11+00:00 2026-05-25T16:39:11+00:00

I have file name which look like Directory\name-secondName-blabla.txt If I using string .split my

  • 0

I have file name which look like

Directory\name-secondName-blabla.txt

If I using string .split my code need to know the separator I am using,
But if in some day I will replace the separator my code will break

Is the any build in way to split to get the following result?

Directory
name
secondNmae
blabla
txt

Thanks

Edit My question is more general than just split file name, is splitting string in general

  • 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-25T16:39:12+00:00Added an answer on May 25, 2026 at 4:39 pm

    The best way to split a filename is to use System.IO.Path

    You’re not clear about what to do with directory1\directory2\ ,
    but in general you should use this static class to find the path, name and suffix parts.

    After that you will need String.Split() to handle the - separators, you’ll just have to make the separator(s) a config setting.

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

Sidebar

Related Questions

I have a file name logspath.txt which contain on the logs directory path on
I have a variable which has the directory path, along with the file name.
I have two XML file sitemap.xml and mouse.xml which look like below.Here the thing
I need help in parsing a very long text file which looks like: NAME
I have a HTML file upload field from which I'm reading the file name
I have this method for grabbing the file name from a string URI. What
I have to search a given file name (let say Keyword) in a directory
I have some source code to get the file name of an url for
My Scenario: I have a known location(directory/path) where a .txt file is going to
I have 600 tab-delimited .txt files that look like this: barcode gene.symbol value 1

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.