Skip to content

Commit 64a6b8f

Browse files
authored
Update demo code
1 parent 4d42e56 commit 64a6b8f

File tree

5 files changed

+27
-13
lines changed

5 files changed

+27
-13
lines changed

VB6DLL/PigObjFsLib.vbw

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
pFileSystemObject = 26, 26, 1003, 374, Z
2-
modFsDeclare = 104, 104, 1081, 452,
1+
pFileSystemObject = 26, 26, 1003, 374,
32
pFile = 130, 130, 1107, 478,
43
pFolder = 130, 130, 1107, 478,
54
PigLog = 78, 78, 1055, 426,

VB6DLL/PigObjFsTestDll.exe

0 Bytes
Binary file not shown.

VB6DLL/PigObjFsTestDll.vbp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Description="Piggy Objectified FileSystemObject test dll"
1515
CompatibleMode="0"
1616
MajorVer=1
1717
MinorVer=0
18-
RevisionVer=14
18+
RevisionVer=15
1919
AutoIncrementVer=1
2020
ServerSupportFiles=0
2121
VersionComments="Class usage examples of pigobjfs"

VB6DLL/PigObjFsTestDll.vbw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
frmPigObjFs = 104, 104, 1142, 429, Z, 26, 26, 1064, 351, C
1+
frmPigObjFs = 104, 104, 1142, 429, , 26, 26, 1064, 351, C
22
modPigObjFs = 0, 0, 0, 0, C

VB6DLL/frmPigObjFs.frm

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ Attribute VB_PredeclaredId = True
6868
Attribute VB_Exposed = False
6969
Option Explicit
7070

71-
Private Sub aaa_Click()
72-
73-
End Sub
7471

7572
Private Sub Form_Load()
7673
Set goFS = New pFileSystemObject
@@ -116,7 +113,7 @@ End Sub
116113

117114
Private Sub mnupFileSystemObject_CreateFolder_Click()
118115
Dim strFolderPath As String
119-
strFolderPath = InputBox("Enter the Folder path", Me.mnupFileSystemObject_CreateFolder.Caption, "c:\temp")
116+
strFolderPath = InputBox("Enter the Folder path", Me.mnupFileSystemObject_CreateFolder.Caption, "c:\temp\a\b\c")
120117
With Me.txtMain
121118
goFS.CreateFolder strFolderPath
122119
.Text = "CreateFolder:" & vbTab
@@ -130,7 +127,7 @@ End Sub
130127

131128
Private Sub mnupFileSystemObject_FileExists_Click()
132129
Dim strFilePath As String
133-
strFilePath = InputBox("Enter the file path", Me.mnupFileSystemObject_FileExists.Caption, App.Path & "\modFsDeclare.bas")
130+
strFilePath = InputBox("Enter the file path", Me.mnupFileSystemObject_FileExists.Caption, Me.GetCurrDirFristFile)
134131
With Me.txtMain
135132
.Text = "FileExists:" & vbTab & goFS.FileExists(strFilePath) & vbCrLf
136133
End With
@@ -146,9 +143,9 @@ Private Sub mnupFileSystemObject_FolderExists_Click()
146143
End Sub
147144

148145
Private Sub mnupFileSystemObject_GetFile_Click()
149-
Dim strFilePath As String
150-
strFilePath = InputBox("Enter the file path", Me.mnupFileSystemObject_GetFile.Caption, App.Path & "\modFsDeclare.bas")
151-
Dim oFile As pFile
146+
Dim oFolder As pFolder
147+
Dim oFile As pFile, strFilePath As String
148+
strFilePath = InputBox("Enter the file path", Me.mnupFileSystemObject_GetFile.Caption, Me.GetCurrDirFristFile)
152149
Set oFile = goFS.GetFile(strFilePath)
153150
If oFile.IsObjReady = True Then
154151
With Me.txtMain
@@ -160,8 +157,26 @@ Private Sub mnupFileSystemObject_GetFile_Click()
160157
Else
161158
MsgBox "oFile.IsObjReady = " & oFile.IsObjReady, vbCritical, Me.mnupFileSystemObject_GetFile.Caption
162159
End If
160+
163161
End Sub
164162

163+
164+
Public Function GetCurrDirFristFile() As String
165+
Dim oFolder As pFolder, objFile As Object, oFile As pFile
166+
Set oFolder = goFS.GetFolder(App.Path)
167+
GetCurrDirFristFile = ""
168+
If oFolder.IsObjReady = True Then
169+
For Each objFile In oFolder.Files
170+
If Not objFile Is Nothing Then
171+
Set oFile = New pFile
172+
Set oFile.Obj = objFile
173+
GetCurrDirFristFile = oFile.Path
174+
Exit For
175+
End If
176+
Next
177+
End If
178+
End Function
179+
165180
Private Sub mnupFileSystemObject_GetFolder_Click()
166181
Dim strDirPath As String
167182
strDirPath = InputBox("Enter the folder path", Me.mnupFileSystemObject_GetFolder.Caption, App.Path)
@@ -182,7 +197,7 @@ End Sub
182197

183198
Private Sub mnupTextStream_ReadFile_Click()
184199
Dim strFilePath As String, strLine As String
185-
strFilePath = InputBox("Input file path", Me.mnupTextStream_ReadFile.Caption, App.Path & "\modFsDeclare.bas")
200+
strFilePath = InputBox("Input file path", Me.mnupTextStream_ReadFile.Caption, App.Path & "\README.cmd")
186201
Dim oTextStream As pTextStream
187202
Set oTextStream = goFS.OpenTextFile(strFilePath, pIOMode.ForReading, True)
188203
If goFS.LastErr <> "" Then

0 commit comments

Comments
 (0)