Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The use of GetParentFolderName method in VBS

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article focuses on "the use of GetParentFolderName method in VBS". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "the use of GetParentFolderName method in VBS"!

GetParentFolderName method

Returns a string containing the parent folder of the last file or folder in the specified path.

Object.GetParentFolderName (path)

Parameters.

Object

Required. Should be the name of FileSystemObject.

Path

Required. Specify the path to return the parent folder name of the file or folder.

Description

If the file or folder specified by the path parameter has no parent folder, the GetParentFolderName method returns a zero-length string (").

The following example illustrates how to use the GetParentFolderName method:

Function GetTheParent (DriveSpec) Dim fsoSet fso = CreateObject ("Scripting.FileSystemObject") GetTheParent = fso.GetParentFolderName (Drivespec) End Function

Note that the GetParentFolderName method only works on strings that provide path. It cannot attempt to analyze a path, nor can it check whether the specified path exists.

For more details, please refer to this article: https://www.jb51.net/shouce/vbs/vsmthGetParentFolderName.htm

Let me share one with you.

VBS script recursively creates a multi-level (hierarchical) directory folder

CreateFolders "d:\ ftptest\ 1\ 2\ 3\ 4\ 5" Function CreateFolders (path) Set fso = CreateObject ("scripting.filesystemobject") CreateFolderEx fso,path set fso = NothingEnd FunctionFunction CreateFolderEx (fso,path) If fso.FolderExists (path) Then Exit Function End If If Not fso.FolderExists (fso.GetParentFolderName (path)) Then CreateFolderEx fso,fso.GetParentFolderName (path) End If fso.CreateFolder (path) End Function

It mainly uses the principle of recursive call to achieve step-by-step directory creation.

At this point, I believe you have a deeper understanding of "the use of the GetParentFolderName method in VBS". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report