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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:36:55+00:00 2026-06-11T01:36:55+00:00

I have filepaths in quotes with empty spaced foldernames like this with at least

  • 0

I have filepaths in quotes with empty spaced foldernames like this with at least two command line parameters of different length and value appended:

“C:\My Program\Sample Folder\SubFolder2\MyApp1.exe” -parameter13XY1 -parameter101XZ2

I would like to have only the filename without quotes and without commandline arguments:

C:\My Program\Sample Folder\SubFolder2\MyApp1.exe

I would search functions like “StripQuotes” and “StripCommandLineArgs” in the framework, but I didn’t find anything similar, since the framework has almost everything missing what would be needed.
As for quotes it would maybe do a “Replace”, but the commandline arguments can’t be sorted out that way. The filename also contains spaces, so it is not possible to work with Split() as it would cut a part of the filename out.

In the end I would like to have only the filename without quotes and commandline arguments. Note that the filename can also contain empty spaces and hyphens and both combinations of it, like this:

“C:\My Program – Win64\Sample-Folder\Sub -Folder3\My App55- .exe -parameter1 -parameter2 para3”

I have no idea how to find out only the valid path in such cases. There could be also five commandline arguments attached or even 10.

  • 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-06-11T01:36:57+00:00Added an answer on June 11, 2026 at 1:36 am

    You can use a regular expression "^\"([^\"]*)\".*$" to get the content of the quoted string, like this:

    var s = "\"C:\\My Program\\Sample Folder\\SubFolder2\\MyApp1.exe\" -parameter13XY1 -parameter101XZ2";
    var res = Regex.Replace(s, "^\"([^\"]*)\".*$", "$1");
    Console.WriteLine(res);
    

    Here is a link to ideone.

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

Sidebar

Related Questions

I have this line in the declarations section: Private filePath As String And something
I have a file which has absolute filepaths listed, 1 per line. The listed
I have a simple SQLCMD script that includes some lines like this: /* Load
I have two lists. Both containing the same values: QStringList filePaths; filePaths.append(C:/backup); filePaths.append(C:/download/file1); filePaths.append(D:);
My program accepts input file names either as command line parameters or in a
I use json data with jquery... I have filepaths in json and i am
I have a function ClassA::FuncA(const char *filePath) and want to copy this const char
I have two string variables which are both file paths. The code that worked
I have this class : public class TempFileRef { public readonly string FilePath; public
So i have this code: foreach (string xmlfilelisted in xmlFileList) { resultXml.Root.Add(XDocument.Load(xmlfilelisted).Root.Elements()); resultXml.Save(filepath); }

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.