我有N个随机文件(自定义结构),每个结构都不同,我想怎么制作一个通用函数,以实现执行特定的操作,把对应的文件重新写到目标路径下(注意,不是用FileCopy拷贝,而是写记录)
例如:
type s1
a1 as byte
a2 as integer
end type
type s2
c1 as byte
c2 as integer
c3 as string
end type
dim s1 as s1
dim s2 as s2
select case n1
case 1
源文件app.path+"s1.fmb",目标文件 path+"s1.fmb"
case 2
源文件app.path+"s2.fmb",目标文件 path+"s2.fmb"
end select
Public Function FileCopys(ByVal Dfile As String, ByVal lenth As Long) As Boolean
Dim gg As Integer
Dim fp1, fp2 As Integer
ReDim ss(lenth)
fp1 = FreeFile
Open DATA_PATH + Dfile For Random Access Read Write Shared As fp1 Len = lenth
fp2 = FreeFile
Open SERVER_PATH + Dfile For Random Access Read Write Shared As fp2 Len = lenth
gg = 1
While Not EOF(fp1)
gg = gg + 1
Get fp1, gg, ss '(gg)
Put fp2, gg, ss '(gg)
Wend
Close fp1
Close fp2
End Function
哪里有问题?
例如:
type s1
a1 as byte
a2 as integer
end type
type s2
c1 as byte
c2 as integer
c3 as string
end type
dim s1 as s1
dim s2 as s2
select case n1
case 1
源文件app.path+"s1.fmb",目标文件 path+"s1.fmb"
case 2
源文件app.path+"s2.fmb",目标文件 path+"s2.fmb"
end select
Public Function FileCopys(ByVal Dfile As String, ByVal lenth As Long) As Boolean
Dim gg As Integer
Dim fp1, fp2 As Integer
ReDim ss(lenth)
fp1 = FreeFile
Open DATA_PATH + Dfile For Random Access Read Write Shared As fp1 Len = lenth
fp2 = FreeFile
Open SERVER_PATH + Dfile For Random Access Read Write Shared As fp2 Len = lenth
gg = 1
While Not EOF(fp1)
gg = gg + 1
Get fp1, gg, ss '(gg)
Put fp2, gg, ss '(gg)
Wend
Close fp1
Close fp2
End Function
哪里有问题?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货