473,473 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ShortPath Name in C#

Hi

Is there any way to get the short path name of the file or folder in C#.
Just like the API "GetShortPathName" in C++

Regards

Usman
Feb 14 '06 #1
5 5639
Hello, Usman!

U> Is there any way to get the short path name of the file or folder in C#.
U> Just like the API "GetShortPathName" in C++

IIRC you will have to P/Invoke to get such functionality
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Feb 14 '06 #2
Hello Vadym,

VS> Hello, Usman!
VS>
U>> Is there any way to get the short path name of the file or folder in
U>> C#. Just like the API "GetShortPathName" in C++
VS> IIRC you will have to P/Invoke to get such functionality

yep, here http://groups.google.de/group/micros...f01196a689c3af

VS> --
VS> Regards, Vadym Stetsyak
VS> www: http://vadmyst.blogspot.com
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Feb 14 '06 #3
Hi

Any Idea how to call this in API in C#. The syntax in the example is for
VB.Net.

Regards

Usman
"Michael Nemtsev" <ne*****@msn.com> wrote in message
news:9c**************************@msnews.microsoft .com...
Hello Vadym,

VS> Hello, Usman!
VS>
U>> Is there any way to get the short path name of the file or folder in
U>> C#. Just like the API "GetShortPathName" in C++
VS> IIRC you will have to P/Invoke to get such functionality

yep, here http://groups.google.de/group/micros...s.vb/msg/ebf01
196a689c3af
VS> --
VS> Regards, Vadym Stetsyak
VS> www: http://vadmyst.blogspot.com
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not cease to be insipid." (c) Friedrich Nietzsche

Feb 15 '06 #4
Hello, Usman!

I suppose it would look like this...

[System.Runtime.InteropServices.DllImport("kernel32 .dll", EntryPoint = "GetShortPathName", SetLastError = true)]
private static extern int PlaySound(string lpszLongPath , string lpszShortPath , int cchBuffer);

string strPath = Application.StartupPath;
string strShortPath = new string(' ', 100);
int n = GetShortPathName(strPath, strShortPath, 100) ;
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Feb 15 '06 #5
For all P/invoke see pinvoke.net

http://www.pinvoke.net/default.aspx/...tPathName.html

"Usman" <us***@advcomm.net> wrote in message
news:uZ*************@TK2MSFTNGP11.phx.gbl...
Hi

Any Idea how to call this in API in C#. The syntax in the example is for
VB.Net.

Regards

Usman
"Michael Nemtsev" <ne*****@msn.com> wrote in message
news:9c**************************@msnews.microsoft .com...
Hello Vadym,

VS> Hello, Usman!
VS>
U>> Is there any way to get the short path name of the file or folder in
U>> C#. Just like the API "GetShortPathName" in C++
VS> IIRC you will have to P/Invoke to get such functionality

yep, here

http://groups.google.de/group/micros...s.vb/msg/ebf01
196a689c3af

VS> --
VS> Regards, Vadym Stetsyak
VS> www: http://vadmyst.blogspot.com
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do

not
cease to be insipid." (c) Friedrich Nietzsche


Feb 15 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
by: stewart.midwinter | last post by:
No doubt I've overlooked something obvious, but here goes: Let's say I assign a value to a var, e.g.: myPlace = 'right here' myTime = 'right now' Now let's say I want to print out the two...
2
by: Ravi | last post by:
My XML looks like: <abc> <def type="apple"> 1 </def> <def type="peach"> 2 </def> <def type="orange"> 3 </def> <def type="banana"> 4 </def> <def type="plum"> 5 </def> </abc>
1
by: discomiller | last post by:
Mario Mueller: Hello *, radiobuttons belong to other radiobuttons by the "name="any_value"" attribut. Thats a fakt. I got the following XML:...
21
by: TheKeith | last post by:
I heard that the name attribute is deprecated in html 4.01 strict. Is it recommended that you use the ID attribute for images along with the getElementById method instead of the old way? Thanks.
12
by: CJ | last post by:
Why won't this work? I am passing the name of the form (I have two that use this validation script) but I keep getting an error. Error reads: "document.which_form.name is null or not an object" ...
11
by: Andrew Thompson | last post by:
I have written a few scripts to parse the URL arguments and either list them or allow access to the value of any parameter by name. <http://www.physci.org/test/003url/index.html>...
1
by: Prasad Karunakaran | last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of an user object in the Active Directory. I need to get the First Name and Last Name as properties. I know it is not supported...
1
by: ivanet | last post by:
Hello everyone, I am trying to use the following Schema but I get the error "src- resolve: Cannot resolve the name 'ValuesList' to a(n) 'element declaration' component." at line 144. I have...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.