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

Posted on 2005-04-29
Last Modified: 2010-04-16
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.
Question by:ice_nin
    LVL 20

    Accepted 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.
    LVL 3

    Expert Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
    In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now