VB6:从文件路径获取文件夹名称的简便方法 [英] VB6: easy way to get folder name from filepath

查看:504
本文介绍了VB6:从文件路径获取文件夹名称的简便方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我具有文件的完整路径:

If I have the full path of a file:

eg. c:\files\file.txt

获取此文件的文件夹的最简单方法是什么:eg. c:\files\?

What would be the easiest way to get the folder of this file: eg. c:\files\ ?

推荐答案

使用FileSystemObject.GetParentFolderName(strFullFilePath)例如

  Dim strFullFilePath As String
  strFullFilePath = "c:\files\file.txt"

  Dim fso
  Set fso = CreateObject("Scripting.FileSystemObject")

  MsgBox fso.GetParentFolderName(strFullFilePath)

请注意,这将返回c:\file而不是c:\file\

Note this returns c:\file rather than c:\file\

这篇关于VB6:从文件路径获取文件夹名称的简便方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆