Solved

PKUNZIP through VB and passing LONG FILENAMES

Posted on 1998-09-30
4
251 Views
Last Modified: 2010-05-18
I am calling PKUNZIP with teh SHELL function and using VB to tell me all the ZIP files that exist in a directory and with that PKUNZIP those files into another directory.
THe problem arises when i use long filenames with PKUNZIP.  It has no clue about long filenames. It only recognizes the 8.3 filename style.  So ie. Shell("PKUNZIP.EXE LONG_FILENAME.ZIP") will not work at all, however, a call like Shell("PKUNZIP.EXE LONG_F~1.ZIP") will work. How do i find out what the equivalent 8.3 format is for a long filename. Some of you may say just pop a ~1 just before the .ZIP extension but what if in the directory there already exists a file with that same name (DOS assigns these unique ~#'s)? I could write a procedure that looks for all files with these long names and starts formulating these 8.3 formats for them, BUT the problem is DOS may have assigned a unique ~# that is different from mine.

Any suggestions?
0
Comment
Question by:ljaques
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
4 Comments
 
LVL 3

Accepted Solution

by:
a111a111a111 earned 10 total points
ID: 1437542
I am sending you the code for short file name from long file name.
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1437543
In module1.bas :
Option Explicit

Declare Function GetShortPathName Lib "kernel32" _
      Alias "GetShortPathNameA" (ByVal lpszLongPath As String, _
      ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long

   Public Function GetShortName(ByVal sLongFileName As String) As String
       Dim lRetVal As Long, sShortPathName As String, iLen As Integer
       'Set up buffer area for API function call return
       sShortPathName = Space(255)
       iLen = Len(sShortPathName)

       'Call the function
       lRetVal = GetShortPathName(sLongFileName, sShortPathName, iLen)
       'Strip away unwanted characters.
       GetShortName = Left(sShortPathName, lRetVal)
   End Function


in form1:

Private Sub Command1_Click()
Dim msg As String
     CommonDialog1.filename = "*.*"
     CommonDialog1.ShowOpen
     
     msg = "Long File Name: " & CommonDialog1.filename & vbCrLf
     msg = msg & "Short File Name: " & GetShortName(CommonDialog1.filename)
     msg = msg & vbCrLf & "________________________________________________________"
     msg = msg & vbCrLf & vbCrLf & "http://www.hili.com/~shay   E-Mail: shayplace@hotmail.com"
     
     MsgBox msg
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Form_Load()

End Sub


You can download the complete project form my site as
http://www.hili.com/~shay/filename.zip


0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1437544
In module1.bas :
Option Explicit

Declare Function GetShortPathName Lib "kernel32" _
      Alias "GetShortPathNameA" (ByVal lpszLongPath As String, _
      ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long

   Public Function GetShortName(ByVal sLongFileName As String) As String
       Dim lRetVal As Long, sShortPathName As String, iLen As Integer
       'Set up buffer area for API function call return
       sShortPathName = Space(255)
       iLen = Len(sShortPathName)

       'Call the function
       lRetVal = GetShortPathName(sLongFileName, sShortPathName, iLen)
       'Strip away unwanted characters.
       GetShortName = Left(sShortPathName, lRetVal)
   End Function


in form1:

Private Sub Command1_Click()
Dim msg As String
     CommonDialog1.filename = "*.*"
     CommonDialog1.ShowOpen
     
     msg = "Long File Name: " & CommonDialog1.filename & vbCrLf
     msg = msg & "Short File Name: " & GetShortName(CommonDialog1.filename)
     msg = msg & vbCrLf & "________________________________________________________"
     msg = msg & vbCrLf & vbCrLf & "http://www.hili.com/~shay   E-Mail: shayplace@hotmail.com"
     
     MsgBox msg
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Form_Load()

End Sub


You can download the complete project form my site as
http://www.hili.com/~shay/filename.zip


0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1437545
Sorry for the duplicate here the server has a problem.

Go and download the project from the site:
http://www.hili.com/~shay/filename.zip 

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question