FindFile file type question
-
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 ThenstrFile = 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
-
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 ThenstrFile = 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
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