Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. FindFile file type question

FindFile file type question

Scheduled Pinned Locked Moved Visual Basic
questiontutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    monsieur_jj
    wrote on last edited by
    #1

    Hi all, I am new to vb and I am trying to get the file type of every file found during findfile here is my code:

    iSearchHandle = FindFirstFile(SrcDir, pFindFileBuff)
    If iSearchHandle <> INVALID_HANDLE_VALUE Then

        strFile = TrimNull(pFindFileBuff.cFileName)
        Do While strFile <> ""
            Do While FindNextFile(iSearchHandle, pFindFileBuff)
            strFile = TrimNull(pFindFileBuff.cFileName)
            If strFile <> "." And strFile <> ".." Then
            strFile = strDir + "\\" + strFile
            'strLen = Len(strFile)
            
            fileType = Right$(strFile, 4)
    

    I tried using Right$ to get the file type for example "TonyRobertson.ppsx", ,"version2.5.0.doc", "IMIT031211_TonyRobertson.ppt" and "MARBLES.G4" by using that I get ppsx, .doc, .ppt and S.G4, is there another way to get the right format? Thanks, Jj

    A 1 Reply Last reply
    0
    • M monsieur_jj

      Hi all, I am new to vb and I am trying to get the file type of every file found during findfile here is my code:

      iSearchHandle = FindFirstFile(SrcDir, pFindFileBuff)
      If iSearchHandle <> INVALID_HANDLE_VALUE Then

          strFile = TrimNull(pFindFileBuff.cFileName)
          Do While strFile <> ""
              Do While FindNextFile(iSearchHandle, pFindFileBuff)
              strFile = TrimNull(pFindFileBuff.cFileName)
              If strFile <> "." And strFile <> ".." Then
              strFile = strDir + "\\" + strFile
              'strLen = Len(strFile)
              
              fileType = Right$(strFile, 4)
      

      I tried using Right$ to get the file type for example "TonyRobertson.ppsx", ,"version2.5.0.doc", "IMIT031211_TonyRobertson.ppt" and "MARBLES.G4" by using that I get ppsx, .doc, .ppt and S.G4, is there another way to get the right format? Thanks, Jj

      A Offline
      A Offline
      Ashutosh Phoujdar
      wrote on last edited by
      #2

      Hope you are using VB6. There are two options to get the file type e.g. 1. Split the filename using (.) dot character and get last element in array. 2. Use FileSystemObject, that provides a lot more options on file information. For more information : Click[^] PS: If you are using VB.NET then there are lot of utility classes in System.IO Namespace[^]

      dnpro "Very bad programmer" My Latest Articles RichTextBox Control with Find functionality LogViewer - A Simple Log Listening Utility

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups