473,378 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Path in DOS format

Hi,
How do you get the returned path from
FolderBrowserDialog.SelectedPath in DOS format (8-
characters-long folder names)?

That is:
If the returned path is: C:\Program Files\My Folders
I will get: C:\Progra~1\MyFold~1
Nov 20 '05 #1
6 4895
* "Amjad" <am*********@hotmail.com> scripsit:
How do you get the returned path from
FolderBrowserDialog.SelectedPath in DOS format (8-
characters-long folder names)?

That is:
If the returned path is: C:\Program Files\My Folders
I will get: C:\Progra~1\MyFold~1


I am interested in the reason why you need that...

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Hi, Herfried:

Some people still need to shell a DOS based application... :'-(

The solution comes through the API function GetShortPathName: http://msdn.microsoft.com/library/de...rtpathname.asp.

Regards.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> escribió en el mensaje news:bn************@ID-208219.news.uni-berlin.de...
| * "Amjad" <am*********@hotmail.com> scripsit:
| > How do you get the returned path from
| > FolderBrowserDialog.SelectedPath in DOS format (8-
| > characters-long folder names)?
| >
| > That is:
| > If the returned path is: C:\Program Files\My Folders
| > I will get: C:\Progra~1\MyFold~1
|
| I am interested in the reason why you need that...
|
| --
| Herfried K. Wagner
| MVP · VB Classic, VB.NET
| <http://www.mvps.org/dotnet>
Nov 20 '05 #3
* José Manuel Agüero <jmªgue®ø@v°daƒøne.e§> scripsit:
Some people still need to shell a DOS based application... :'-(
Thanks, I didn't think of that...
The solution comes through the API function GetShortPathName:
http://msdn.microsoft.com/library/de...rtpathname.asp.


Problem solved?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
> Problem solved?

Yes, but...

If someone likes something, somehow... managed, there is another solution:
Put a reference to Scripting type library in the project and create a FileSystemObject (see http://msdn.microsoft.com/library/de...jectmodel.asp).
Now you can use the ShortPath Property of the "File" and "Folder" objects (see http://msdn.microsoft.com/library/de...shortpath.asp).

Note (I say for Amjad, I'm sure you know, Herfried) that Scripting is part of the system automation model and is frecuently disabled for security reasons. Have it in mind if you want to distribute your application.

Regards.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> escribió en el mensaje news:bn************@ID-208219.news.uni-berlin.de...
| * José Manuel Agüero <jmªgue®ø@v°daƒøne.e§> scripsit:
| > Some people still need to shell a DOS based application... :'-(
|
| Thanks, I didn't think of that...
|
| > The solution comes through the API function GetShortPathName:
| > http://msdn.microsoft.com/library/de...rtpathname.asp.
|
| Problem solved?
|
| --
| Herfried K. Wagner
| MVP · VB Classic, VB.NET
| <http://www.mvps.org/dotnet>
Nov 20 '05 #5
Thanks. You were right about the reason of why I'd need
the short path naming scheme in my program.

However, I tried the "GetShortPathName" function and VB
said it's not declared. How do I declare it?
Do you have a sample code on how to use this function in
VB .NET?

I'm trying to avoid using FileSystemObject option. I'm
looking for a simple string manipulation solution.

Amjad
-----Original Message-----
Problem solved?
Yes, but...

If someone likes something, somehow... managed, there is

another solution:Put a reference to Scripting type library in the project and create a FileSystemObject (see
http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/vbcn7/html/vbconintroductiontofilesystemobjectmodel.asp
).Now you can use the ShortPath Property of the "File" and "Folder" objects (see
http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/script56/html/jsproshortpath.asp).
Note (I say for Amjad, I'm sure you know, Herfried) that Scripting is part of the system automation model and is
frecuently disabled for security reasons. Have it in mind
if you want to distribute your application.
Regards.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> escribió en el mensaje news:bn726g$u6fos$2@ID-
208219.news.uni-berlin.de...| * José Manuel Agüero <jmªgue®ø@v°daføne.e§> scripsit:
| > Some people still need to shell a DOS based application... :'-(|
| Thanks, I didn't think of that...
|
| > The solution comes through the API function GetShortPathName:| > http://msdn.microsoft.com/library/default.asp? url=/library/en-us/fileio/base/getshortpathname.asp.|
| Problem solved?
|
| --
| Herfried K. Wagner
| MVP · VB Classic, VB.NET
| <http://www.mvps.org/dotnet>
.

Nov 20 '05 #6
Hello, Amjad:

Here is an example written in two minutes:

class chema_gspn
declare auto function GetShortPathName lib "kernel32" (byval lpszLongPath as string, byval lpszShortPath as string, byval cchBuffer as integer) as integer
public shared sub Main()
dim result as new string(" "c,260) 'Needs to contain something.
call getshortpathname("C:\Documents and Settings\Chema\Mis documentos\Mis archivos recibidos", result, microsoft.visualbasic.len(result))
system.console.writeline(result.substring(0,result .indexof(char.minvalue))) 'Only get string until chr(0) found.
system.console.readline
end sub
end class
It's not perfect: "len" returns the number of characters, not the number of bytes, wich is what we need...; it has no error checking...; (put your own objections here)...

Regards.
"Amjad" <am*********@hotmail.com> escribió en el mensaje news:0b****************************@phx.gbl...
Thanks. You were right about the reason of why I'd need
the short path naming scheme in my program.

However, I tried the "GetShortPathName" function and VB
said it's not declared. How do I declare it?
Do you have a sample code on how to use this function in
VB .NET?

I'm trying to avoid using FileSystemObject option. I'm
looking for a simple string manipulation solution.

Amjad

Nov 20 '05 #7

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

Similar topics

3
by: Xah Lee | last post by:
Split File Fullpath Into Parts Xah Lee, 20051016 Often, we are given a file fullpath and we need to split it into the directory name and file name. The file name is often split into a core...
5
by: Jorg Rødsjø | last post by:
Hi I'm trying to use os.path.getmtime to check if a file has been modified. My OS is WinXP. The problem is, that when the os changes from/to daylight savings time, the result is suddenly off by...
2
by: Garry Freemyer | last post by:
I wrote a screensaver, via Visual Studio 2003 in C# and I decided a wiser choice for me was to use an xml file to save my configs. Btw: I wonder if this is why every bit of documentation I've found...
2
by: Frank Rizzo | last post by:
System.Reflection.Assembly.GetExecuting().GetName().CodeBase return the path in URL format. file:///C:/Code/.../MyFile.DLL Is there a function within the framework to return the standard path...
5
by: raffelm | last post by:
I'm struggling to find a way to include long path names in a command line argument string that I have to build at runtime. I need to create a string like -o:"c:\my documents\my file.txt". ...
10
by: Alpha | last post by:
I use FolderBrowserDlg for user to select a folder path then store it in the sql table. I then retrieve it to concatenate in a sqlcommand text to retrive files from that directory but it won't...
5
by: Jim McGivney | last post by:
In an aspx page I run the following C# code-behind: string filename = null; filename = txtUpload.PostedFile.FileName.Trim(); //save the file...
1
by: WALDO | last post by:
I have a small installation app that I'm building. The user can specify an install path at the command line. How can I ensure that something they put in is valid? What I'm NOT looking for is...
21
by: Hitesh | last post by:
Hi, I get path strings from a DB like: \\serverName\C:\FolderName1\FolderName2\example.exe I am writing a script that can give me access to that exe file. But problem is that string is not...
1
by: Oren | last post by:
Hi, Im working with asp.net visual web developer 2005. Im writing an asp .net application on windows XP enviroment. Im using .net FileUpload control to get the path from the user. If the path is...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.