Results 1 to 4 of 4

Thread: How can i....

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Posts
    116

    How can i....

    get the drive, path, filename, extension from a given string like this:
    "c:\windows\system\blahblah.txt"

    im talking about ready VB functions, if there are any....
    10x,
    Amos

  2. #2
    jim mcnamara
    Guest
    This isn't the answer you want - no easy-to-use builtins
    are available in VB
    Goto VBNET. And search for 'shell path routines'

    It shows api calls for parsing paths, filenames, etc.

    Click here

  3. #3
    Hyperactive Member techman2553's Avatar
    Join Date
    Mar 2001
    Location
    <- To your left.
    Posts
    362
    I don't know of any single commands to give you this info, but this is what I normally use:

    Code:
      Directory = "C:\Windows\System\Test\File.exe"
      
      FilePath = Left(Directory, InStrRev(Directory, "\"))
      FileName = Right(Directory, Len(Directory) - InStrRev(Directory, "\"))
      FileExtension = Right(Directory, Len(Directory) - InStrRev(Directory, "."))
      DriveLetter = Left(Directory, 1)
    ----------

  4. #4
    Matthew Gates
    Guest
    Try this:


    Code:
    Private Sub Form_Load()
        Dim sFilePath As String
        Dim sDrive As String
        Dim sPath As String
        Dim sFile As String
        Dim sExtension As String
        
        Me.AutoRedraw = True
        
        sFilePath = "c:\windows\system\blahblah.txt"
        
        sDrive = Left$(sFilePath, 3)
        sPath = Mid$(sFilePath, 3, InStrRev(sFilePath, "\") - 2)
        sFile = Mid$(sFilePath, InStrRev(sFilePath, "\") + 1)
        sExtension = Mid$(sFilePath, InStrRev(sFilePath, "\") + InStr(Mid$(sFilePath, InStrRev(sFilePath, "\") + 1), "."))
        
        Print sDrive
        Print sPath
        Print sFile
        Print sExtension
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width