VBS中怎么瀏覽本地文件-創(chuàng)新互聯(lián)

VBS中怎么瀏覽本地文件,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。

你所需要的網(wǎng)站建設(shè)服務(wù),我們均能行業(yè)靠前的水平為你提供.標(biāo)準(zhǔn)是產(chǎn)品質(zhì)量的保證,主要從事網(wǎng)站制作、成都網(wǎng)站建設(shè)、企業(yè)網(wǎng)站建設(shè)、手機網(wǎng)站開發(fā)、網(wǎng)頁設(shè)計、高端網(wǎng)站設(shè)計、網(wǎng)頁制作、做網(wǎng)站、建網(wǎng)站。成都創(chuàng)新互聯(lián)公司擁有實力堅強的技術(shù)研發(fā)團隊及素養(yǎng)的視覺設(shè)計專才。

因為系統(tǒng)組件差異,所以代碼也有不同文章最后我們給出一個通用的代碼

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.ShowOpenIf intResult <> 0 ThenBrowseForFile = objDialog.FileNameexit functionelsemsgbox "Error."End Ifend functionBrowseForFile

2003下'for windows 2003

Function SelectAFileSet objDialog = CreateObject("SAFRCFileDlg.FileOpen")intResult = objDialog.OpenFileOpenDlgSelectAFile = objDialog.FileNameEnd Function

瀏覽器方式:

Function BrowseForFile( ) '===========2, fileselect in IE ======================  'Another way to get file path  Dim objIE, strSelected  BrowseForFile = ""  Set objIE = CreateObject( "InternetExplorer.Application" )objIE.ToolBar = FalseobjIE.Resizable = FalseobjIE.StatusBar = False objIE.Width = 300objIE.Height = 100  objIE.visible = True  objIE.Navigate( "about:blank" )  Do Until objIE.ReadyState = 4  Loop ' Center the dialog window on the screen With objIE.Document.ParentWindow.Screen objIE.Left = (.AvailWidth - objIE.Width ) \ 4 objIE.Top = (.Availheight - objIE.Height) \ 4 End With   objIE.Document.Write "<HTML><BODY><INPUT ID=""FileSelect"" NAME=""FileSelect"" TYPE=""file""><BODY></HTML>"  With objIE.Document.all.FileSelect    .focus    .click    strSelected = .value  End With  objIE.Quit  Set objIE = Nothing   If Trim(strSelected) = "" Then Msgbox "You selected no file." Wscript.Quit End If BrowseForFile = strSelectedEnd FunctionBrowseForFile

有沒有發(fā)現(xiàn)上面的代碼運行不易啊,這里我們小編為大家分享一個可用的,雖然上面的的代碼不能用但學(xué)習(xí)參考一下還是不錯的,現(xiàn)在因為平臺愿意導(dǎo)致,原來這些代碼都是可以使用的。

Function ChooseFile()   Dim Result   Result = ""   Dim IE : Set IE = CreateObject("InternetExplorer.Application")   With IE     .Visible = False     .Navigate("about:blank")     Do Until .ReadyState = 4 : Loop     With .Document       .Write "<html><body><input id='f' type='file'></body></html>"       With .All.f         .Focus         .Click         Result = .Value       End With     End With     .Quit   End With   Set IE = Nothing  ChooseFile = ResultEnd FunctionChooseFile

看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識有進一步的了解或閱讀更多相關(guān)文章,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,的支持。

文章名稱:VBS中怎么瀏覽本地文件-創(chuàng)新互聯(lián)
本文地址:http://bm7419.com/article32/ipcsc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、營銷型網(wǎng)站建設(shè)、全網(wǎng)營銷推廣微信小程序、虛擬主機網(wǎng)站收錄

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)