九色国产,午夜在线视频,新黄色网址,九九色综合,天天做夜夜做久久做狠狠,天天躁夜夜躁狠狠躁2021a,久久不卡一区二区三区

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
自動(dòng)化FSO方法
在QTP中使用Vbscr
ipt來(lái)做文件處理時(shí)我們往往會(huì)使用FSO組件來(lái)進(jìn)行操作,一般我們會(huì)使用此組件來(lái)用作日志和結(jié)果的輸出,此處的對(duì)象創(chuàng)建方式為Scripting.filesystemobject, 下面列舉常用的一些操作:
如何新建一個(gè)文本文件?
如何檢查文件是否存在?
如何在文件中寫(xiě)入內(nèi)容?
如何讀取文件中的行?
如何讀取文件中完整的內(nèi)容?
如何關(guān)閉已經(jīng)打開(kāi)的文件?
如何拷貝文件?
如何刪除文件?
如何創(chuàng)建文件夾?
如何獲取文件內(nèi)容的行數(shù)?
腳本實(shí)例:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
Dim objFso
' creating the file system object
Set objFso = CreateObject ("Scripting.FileSystemObject")
' Create a new txt file
' Parameters:
' FilePath - location of the file and its name
Function CreateFile (StrFilePath)
' variable that will hold the new file object
Dim NewFile
' create the new text File
Set NewFile = objFso.CreateTextFile(StrFilePath, True)
Set CreateFile = NewFile
End Function
' Check if a specific file exist
' Parameters:
' FilePath - location of the file and its name
Function CheckFileExists (StrFilePath)
' check if file exist
CheckFileExists = objFso.FileExists(StrFilePath)
End Function
' Write data to file
' Parameters:
' FileRef - reference to the file
' str - data to be written to the file
Function WriteToFile (byref FileRef,str)
' write str to the text file
FileRef.WriteLine(str)
End Function
' Read line from file
' Parameters:
' FileRef - reference to the file
Function ReadLineFromFile (byref FileRef)
' read line from text file
ReadLineFromFile = FileRef.ReadLine
End Function
' Read Entire Text File Test
' Parameters:
' FileRef - reference to the file
Function ReadTextFileTest(StrFilePath)
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f, Msg
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(StrFilePath, ForReading)
ReadTextFileTest = f.Readall()
End Function
' Closes an open file.
' Parameters:
' FileRef - reference to the file
Function CloseFile (byref FileRef)
FileRef.close
End Function
' Opens a specified file and returns an object
' that can be used to read from, write to, or append to the file.
' Parameters:
' FilePath - location of the file and its name
' mode options are:
' ForReading - 1
' ForWriting - 2
' ForAppending - 8
Function OpenFile (StrFilePath,mode)
' open the txt file and retunr the File object
set OpenFile = objFso.OpenTextFile(StrFilePath, mode, True)
End Function
' Copy file.
' Parameters:
' FileRef - reference to the file
Sub FileCopy ( StrFilePathSource,StrFilePathDest)
' copy source file to destination file
objFso.CopyFile StrFilePathSource, StrFilePathDest
End Function
' Delete a file.
' Parameters:
' FileRef - reference to the file
Sub FileDelete ( StrFilePath)
' copy source file to destination file
objFso.DeleteFile ( StrFilePath)
End Function
' Create Folder if Not Exists.
Function ReportFolderStatus(fldr)
Dim fso, msg
Set fso = CreateObject("Scripting.FileSystemObject")
If Not (fso.FolderExists(fldr)) Then
Set f = fso.CreateFolder(fldr)
End If
End Function
ReportFolderStatus("C:\iquicktest")
' Count Number of Lines in txt file
Function NumberOfLines(FileName)
i = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(FileName, ForReading)
Do Until objTextFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objTextFile.ReadLine
i = i +1
Loop
NumberOfLines = UBound(arrFileLines)
objTextFile.Close
End Function
msgbox NumberOfLines("C:\iquicktest\vbs.txt")
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶(hù)發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
檢查上傳文件是否存在同名文件并改名的源代碼
教你快速刪除電腦久存的無(wú)用文件夾 為電腦騰出空間
求一段獲取上傳文件大小的js代碼
整理了一些初學(xué)者常用的ASP代碼
【VBA】判斷文件或文件夾是否存在
ASP操作EXCEL文件
更多類(lèi)似文章 >>
生活服務(wù)
熱點(diǎn)新聞
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服