How to get full pathnames with startup arguments?

G

Guest

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?
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 
G

Guest

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/Upload...rticleID=63e02c1f-761f-44ab-90dd-8d2348b8c6d2


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



Nicholas Paldino said:
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]
- (e-mail address removed)

Robert W. said:
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?
 
N

Nicholas Paldino [.NET/C# MVP]

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]
- (e-mail address removed)

Robert W. said:
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/Upload...rticleID=63e02c1f-761f-44ab-90dd-8d2348b8c6d2


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



Nicholas Paldino said:
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]
- (e-mail address removed)

Robert W. said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top