Scripting.FileSystemObject is a powerful utility, that is often used in Scripting languages.
In [here], the Scripting.FileSystemObject is used to verify if a folder exists. It can be also used to parse a filename. For example,
1 2 3 4 5 6 7 8 9 | ' Parse a Path Name Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.GetFile("C:\Go\Robots.txt") WScript.Echo "Absolute path: " & objFSO.GetAbsolutePathName(objFile) WScript.Echo "Parent folder: " & objFSO.GetParentFolderName(objFile) WScript.Echo "File name: " & objFSO.GetFileName(objFile) WScript.Echo "Base name: " & objFSO.GetBaseName(objFile) WScript.Echo "Extension name: " & objFSO.GetExtensionName(objFile) |
' Parse a Path Name Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.GetFile("C:\Go\Robots.txt") WScript.Echo "Absolute path: " & objFSO.GetAbsolutePathName(objFile) WScript.Echo "Parent folder: " & objFSO.GetParentFolderName(objFile) WScript.Echo "File name: " & objFSO.GetFileName(objFile) WScript.Echo "Base name: " & objFSO.GetBaseName(objFile) WScript.Echo "Extension name: " & objFSO.GetExtensionName(objFile)
will produce the following if the file Robots.txt exists, otherwise ‘File Not Found’ Exception will be thrown out.
Absolute path: C:\Go\robots.txt Parent folder: C:\Go File name: robots.txt Base name: robots Extension name: txt
–EOF (The Ultimate Computing & Technology Blog) —
GD Star Rating
loading...
211 wordsloading...
Last Post: Using Minimum Spanning Tree to Solve the Graph-releated Problem: Learning Languages
Next Post: Compute e Again