By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,997 Members | 1,098 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,997 IT Pros & Developers. It's quick & easy.

How to get full pathnames with startup arguments?

P: n/a
In my WinForms app I'm retrieving the command line arguments with this
standard code: static void Main(string[] args)

Here's the problem. I've now associated my app with a particular extension;
let's call it ".abc". This way if a user is using Windows Explorer they can
double-click on a ".abc" data file and my app will be automatically started.
This works fine except for one thing.

Let's say the datafile is called "Big Tree.abc". Instead of this full
filename being passed to my app, I get "big~1.abc" instead.

What do I have to do to retrieve the full filename?

--
Robert W.
Vancouver, BC
www.mwtech.com

May 21 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Robert,

Mind, you, unless you are displaying the name of the file, there isn't a
reason to convert it, since it will just work in any functions that you need
it to.

If you want to get the full name, call the GetLongPathName through the
P/Invoke layer.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:F6**********************************@microsof t.com...
In my WinForms app I'm retrieving the command line arguments with this
standard code: static void Main(string[] args)

Here's the problem. I've now associated my app with a particular
extension;
let's call it ".abc". This way if a user is using Windows Explorer they
can
double-click on a ".abc" data file and my app will be automatically
started.
This works fine except for one thing.

Let's say the datafile is called "Big Tree.abc". Instead of this full
filename being passed to my app, I get "big~1.abc" instead.

What do I have to do to retrieve the full filename?

--
Robert W.
Vancouver, BC
www.mwtech.com

May 21 '06 #2

P: n/a
Nicholas,

Yes, it has to do with displaying the full filename in the title bar, as
well as the aesthetics of using Save As.

After much more research I found this excellent article:
http://www.c-sharpcorner.com/UploadF...d-8d2348b8c6d2
--
Robert W.
Vancouver, BC
www.mwtech.com

"Nicholas Paldino [.NET/C# MVP]" wrote:
Robert,

Mind, you, unless you are displaying the name of the file, there isn't a
reason to convert it, since it will just work in any functions that you need
it to.

If you want to get the full name, call the GetLongPathName through the
P/Invoke layer.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:F6**********************************@microsof t.com...
In my WinForms app I'm retrieving the command line arguments with this
standard code: static void Main(string[] args)

Here's the problem. I've now associated my app with a particular
extension;
let's call it ".abc". This way if a user is using Windows Explorer they
can
double-click on a ".abc" data file and my app will be automatically
started.
This works fine except for one thing.

Let's say the datafile is called "Big Tree.abc". Instead of this full
filename being passed to my app, I get "big~1.abc" instead.

What do I have to do to retrieve the full filename?

--
Robert W.
Vancouver, BC
www.mwtech.com


May 21 '06 #3

P: n/a
Robert,

You might want to try http://www.pinvoke.net for the P/Invoke
declarations, as it has quite a comprehensive list. It will prevent you
from having to search all over the web.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:EE**********************************@microsof t.com...
Nicholas,

Yes, it has to do with displaying the full filename in the title bar, as
well as the aesthetics of using Save As.

After much more research I found this excellent article:
http://www.c-sharpcorner.com/UploadF...d-8d2348b8c6d2
--
Robert W.
Vancouver, BC
www.mwtech.com

"Nicholas Paldino [.NET/C# MVP]" wrote:
Robert,

Mind, you, unless you are displaying the name of the file, there
isn't a
reason to convert it, since it will just work in any functions that you
need
it to.

If you want to get the full name, call the GetLongPathName through
the
P/Invoke layer.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:F6**********************************@microsof t.com...
> In my WinForms app I'm retrieving the command line arguments with this
> standard code: static void Main(string[] args)
>
> Here's the problem. I've now associated my app with a particular
> extension;
> let's call it ".abc". This way if a user is using Windows Explorer
> they
> can
> double-click on a ".abc" data file and my app will be automatically
> started.
> This works fine except for one thing.
>
> Let's say the datafile is called "Big Tree.abc". Instead of this full
> filename being passed to my app, I get "big~1.abc" instead.
>
> What do I have to do to retrieve the full filename?
>
> --
> Robert W.
> Vancouver, BC
> www.mwtech.com
>


May 21 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.