使用VBS通过3种方式浏览本地文件,获取完整路径。

这篇博客介绍了如何使用VBS(Visual Basic Script)在Windows XP和2003系统中通过两种不同的方法浏览本地文件并获取文件的完整路径。在XP系统下,利用UserAccounts.CommonDialog对象实现;而在2003系统下,通过创建SAFRCFileDlg.FileOpen对象来实现文件选择。同时,还提及在Win7/IE8环境下可能存在的路径返回问题。
摘要由CSDN通过智能技术生成

XP下:

Function BrowseForFile( )
' Select File dialog based on a script by Mayayana
' Known issues:
' * Tree view always opens Desktop folder
' * In Win7/IE8 only the file NAME is returned correctly, the path returned will always be C:\fakepath\
' * If a shortcut to a file is selected, the name of that FILE will be returned, not the shortcut's
    On Error Resume Next 
 '===========1, file browserer in XP ==================
 Set objDialog = CreateObject("UserAccounts.CommonDialog")
 objDialog.Filter = "txt|*.txt"
 objDialog.InitialDir = "C:\"
 intResult = objDialog.ShowOpen
 If intResult <> 0 Then
  BrowseForFile = objDialog.FileName
  exit function
 else
  msgb

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值