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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:48:27+00:00 2026-05-24T00:48:27+00:00

My question is rather unique and I couldn’t find any solution yet. I had

  • 0

My question is rather unique and I couldn’t find any solution yet.

I had a WinForms program that processed the Command line arguments (it is integrated into the context menu and it is called with the directory name of which it was opened on). It worked like charm. The call was like this: myprogram.exe '%1' – where %1 is the directory name.

I tried to create a WPF application with the same method: integrated into the context menu, with the same signature. (myWPFprogram.exe '%1'), using Environment.GetCommandlineArguments().

There is a directory existence check at the beginning of the program. In the WinForms program it has never been triggered (as it was run from the directory I clicked on, so it should have been strange not being existing). With my WPF program I ALWAYS get the message:

An error occurred: The provided directory (‘d:\workbench\dialogs’) doesn’t exist.

I clicked on that directory so it is existing.

Other strange thing that if there is a space in the directory’s name, it becomes ‘truncated’ like in old DOS-times:

An error occurred: The provided directory (‘d:\workbe~1\testsp~1’) doesn’t exist.

How should I get the proper directory name from WPF Command line? What is the problem with my approach?

  • 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-24T00:48:29+00:00Added an answer on May 24, 2026 at 12:48 am

    The problem is that you enclose the argument in single quotes. This doesn’t work, and the argument your program receives is actually something like 'd:\workbench\dialogs' (notice the single quotes).

    If you want to fix this, use double quotes. They are recognized and the argument you are going to receive will be something like: d:\workbench\dialogs. I have no idea why this worked with your WinForms application, because it should behave exactly the same.

    The fact that long names are converted to short names is there probably for compatibility purposes and it shouldn’t bother you. Both versions of the path should work equally fine. If you want to get the normal version of the path, you can use Path.GetFullPath().

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

Sidebar

Related Questions

I searched google but couldn't find an answer to this rather simple question. I
I understand that the question is rather hard to understand, I didn't know how
I have a general question that is rather open-ended (i.e. depends on platform, application
This is admittedly a rather loose question. My current understanding of singletons is that
I have a rather unique problem that I'm having trouble solving. I have a
The question is rather straightforward but not answered by searching. How do I determine
I think this question is rather easy for you shell scripting monsters. I am
Rather Trivial Question. So I tried to do this: if (array[0]==some_string) where array is
I'm relatively new to SVN and have a rather basic question. I have several
Rather a simple question. But the implications are vast. Over the last few weeks

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.