• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 176
  • Last Modified:

C# main and Spacey paths - Kindo of an silly one!

I have an application that will take 2 parameters both of them paths. i came across a bug in my code that im not sure how to fix

From the title you can guess that its something to do with spacey paths.

Is there anyway (without having to put quotes around the path) of getting the whole path and not just a partial path if it contains spaces.
1 Solution
No, if you don't include the quotes around the path, the space means "next parameter", so your application will have more parameters, all of them parts of files but you cannot know where the first one ends and where the second one starts.
However, if you know what the paths are to be like, you can combine 3 or more parameters you get into 2 paths. For example, if you know that you are getting 2 paths none of which has more then 1 consequtive space, and you have received 5 parameters, then you can get only 4 different sets of possible values.

You may create a function that assignes some score to each variant and select the one with the top score, or you may test if a path exists if it should, and so on....

If paths should exist, you can try to append parameters one by one: get the list of entries in the current directory and see if you can create a valid entry adding the next parameter separated by arbitrary number of spaces.

So, if there is no additional data on the paths, then the answer is NO. If there is such data, the answer is MAYBE YES.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now