VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This code uses a FileSystemObject To find the File Base Name, File Extension, File Name, The Parent

by BuBa_kInG (6 Submissions)
Category: Files/File Controls/Input/Output
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 6th December 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This code uses a FileSystemObject To find the File Base Name, File Extension, File Name, The Parent Folder, The 3 Special Folders and a

Rate This code uses a FileSystemObject To find the File Base Name, File Extension, File Name, The Parent



Call GetFileStuff("c:\autoexec.bat") ' whatever!
End Sub

Sub GetFileStuff(FilePath)

Dim Fso, BaseName, Extension, FileName, Path
Set Fso = CreateObject("Scripting.FileSystemObject") 'Create the file system object, DUH!
'filesystem stuff
BaseName = Fso.getbasename(FilePath) ' Gets the filename whitout the path and Extension!
Extension = Fso.GetExtensionName(FilePath) ' Gets the file Extension!
FileName = Fso.getfilename(FilePath) ' Gets the long Filename whit the Extension
Path = Fso.GetParentFolderName(FilePath) ' the folder the file isin

Text1.Text = "Basename: " & BaseName & " Extension: " & Extension & " FileName: " & FileName & " Folder: " & Path

'Other Filesystem stuff

For i = 0 To 2 'this lists all the SpecialFolders: WindowsFolder, SystemFolder, TemporaryFolder in a list box
Dim SF
SF = Fso.GetSpecialFolder(i)
List1.AddItem SF 'adds the Special folder to a list
Next

Dim tempfile
tempfile = Fso.GetTempName 'Returns a randomly generated temporary file or folder name that is useful for performing operations that require a temporary file or folder.

End Sub


Download this snippet    Add to My Saved Code

This code uses a FileSystemObject To find the File Base Name, File Extension, File Name, The Parent Comments

No comments have been posted about This code uses a FileSystemObject To find the File Base Name, File Extension, File Name, The Parent. Why not be the first to post a comment about This code uses a FileSystemObject To find the File Base Name, File Extension, File Name, The Parent.

Post your comment

Subject:
Message:
0/1000 characters