|
-
Aug 2nd, 2001, 07:15 AM
#1
Thread Starter
New Member
Converting a File path and name to DOS format.
Is there any way (in VB5) to take a file path and name taken from a common dialog control and convert it to DOS format?
e.g. C:\hello\thisislongerthan8letters\file.bas
would go to
C:\hello\thisis~1\file.bas
Neil
HTML, JavaScript, QBasic and learning VB5
Mod at http://www.htmlhelpcentral.com
-
Aug 2nd, 2001, 07:35 AM
#2
-= B u g S l a y e r =-
VB Code:
'Make a new project. Add a module. To the form add a command button.
'Code:
'Add this code to the module:
Declare Function GetShortPathName Lib "kernel32" Alias _
"GetShortPathNameA" (ByVal lpszLongPath As String, ByVal _
lpszShortPath As String, ByVal lBuffer As Long) As Long
'Add this code to the form's General Declarations procedure:
Public Function GetShortPath(strFileName As String) _
As String
Dim lngRes As Long
Dim strPath As String
strPath = String$(165, 0)
lngRes = GetShortPathName(strFileName, strPath, 164)
GetShortPath = Left$(strPath, lngRes)
End Function
'Add this code to the command button:
Private Sub Command1_Click()
Dim StrShortPath As String
StrShortPath = GetShortPath("c:\dir\this is long.doc")
End Sub
try that...
-
Aug 2nd, 2001, 07:56 AM
#3
Thread Starter
New Member
It doesnt seem to work for me
Neil
HTML, JavaScript, QBasic and learning VB5
Mod at http://www.htmlhelpcentral.com
-
Aug 2nd, 2001, 08:03 AM
#4
-= B u g S l a y e r =-
what happens... u get an errormsg ?
-
Aug 2nd, 2001, 08:10 AM
#5
-= B u g S l a y e r =-
oh.. think I see what the problem is.. it's returning "" if the file or directory does not exist.
I forgot that .. sorry
-
Aug 2nd, 2001, 08:43 AM
#6
Thread Starter
New Member
Neil
HTML, JavaScript, QBasic and learning VB5
Mod at http://www.htmlhelpcentral.com
-
Aug 2nd, 2001, 08:57 AM
#7
-= B u g S l a y e r =-
hmm.. not sure u need to fix anything, you dont need the short name of a file or dir. that does not exist ?
Or do you ?
-
Aug 2nd, 2001, 09:13 AM
#8
Thread Starter
New Member
What I want it for is a win32 IDE for QuickBasic. I am currently coding the compiler bit and instead of takling ages to write my own (and I couldn't anyway) I am using bc.exe and link.exe that come with QB. I get the filename from a common dialog control and I use shell to start up the program with all these files in the command line. Now the dos compilers spit out the error if the dir's or file names are longer than 8 characters (perfectly natural, they are in dos) so I need to make sure the file names and paths are dos compliant.
This has me stumped, any other suggestions?
Neil
HTML, JavaScript, QBasic and learning VB5
Mod at http://www.htmlhelpcentral.com
-
Aug 2nd, 2001, 09:24 AM
#9
Frenzied Member
use above code w/
if shorpathname(strPathName) <> vbnullstring then
'do stuff here
else
'the dir doesn't exist, warn them
Government is another way to say better…than…you.
It’s like ice but no pick, a murder charge that won’t stick,
it’s like a whole other world where you can smell the food,
but you can’t touch the silverware.
Huh, what luck. Fascism you can vote for.
Humph, isn’t that sweet?
And we’re all gonna die some day, because that’s the American way
-Stone Sour
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|