Hi,does anyone know how to find the extension of a file knowing only the name of the file?to be more clear,i want to know the extension of some file with its path and file name-"C:\folder\file "..How do i do it by coding in vb6.0?
Finding the extension of a file
Collapse
X
-
Hi mafaisal,i think u didnt get my question.U've just taken FileName="Test. txt".My question was if i know a file name(just the name and not its extension) and its correct path,can i find its extension using VB6.0?.Take FileName="C:\Fo lder\File".I want to find the extension of the file "File".Originally posted by mafaisalHello,
Try The Following
Dim ExtName as string
Dim FileName as string
FileName = "Test.Txt" ' for example
ExtName = Mid(FileName ,InStrRev(FileN ame , ".")+1, Len(FileName ))
then got ExtName = "Txt"
If not this plz ignore
FaisalComment
-
Hello
Ok Understand
Try this
Add reference microsoft scripting runtime
Code:Dim FSO As New FileSystemObject Dim F1 As File Dim FOL As Folder Set FOL = FSO.GetFolder(Path of File) Dim Ext For Each F1 In FOL.Files Ext = Split(F1.Name, ".") MsgBox Ext(1) Next
Hope this will Help u
Faisal
Originally posted by vdraceilHi mafaisal,i think u didnt get my question.U've just taken FileName="Test. txt".My question was if i know a file name(just the name and not its extension) and its correct path,can i find its extension using VB6.0?.Take FileName="C:\Fo lder\File".I want to find the extension of the file "File".Comment
Comment