前段时间困扰我的.out文件问题已经得到解决,有两种解决方案。
一、简单的方法将源文件编译生成的Ahoi.exe文件放在与考生编的problem.exe和测试的problem.in放在同一目录下即可,但是实际开发时没法用。
二、实际采用的方法思想是“改变当前目录”,短短的一两行代码就可以达到效果:
ChDrive "e:" '改变当前程序的盘符
ChDrive strExamineeProgramsPath+strSingleTestDirectoy
'这里用两个string变量来表示我想更改的路径,实际程序中strExamineeProgramsPath赋的值 '是"E:/AHOI/ExamineePrograms",strSingleTestDirectoy每次都会变化,比如 '050101,050213等。。
聪明的你一定知道为什么了吧,呵呵~~
昨天找到一个非常好的(不是一般的好)VB学习网站,分享一下: http://www.applevb.com/index.html
从其中偶得一段关于文件比较的代码,放出来:
Function CompFile(F1 As String, F2 As String) As Boolean
Dim issame As Boolean
Open F1 For Binary As #1
Open F2 For Binary As #2
issame = True
If LOF(1) <> LOF(2) Then
issame = False
Else
whole& = LOF(1) / 10000 'number of whole 10,000 byte chunks
part& = LOF(1) Mod 10000 'remaining bytes at end of file
buffer1$ = String$(10000, 0)
buffer2$ = String$(10000, 0)
start& = 1
For X& = 1 To whole& 'this for-next loop will get 10,000
Get #1, start&, buffer1$ 'byte chunks at a time.
Get #2, start&, buffer2$
If buffer1$ <> buffer2$ Then
issame = False
Exit For
End If
start& = start& + 10000
Next
buffer1$ = String$(part&, 0)
buffer2$ = String$(part&, 0)
Get #1, start&, buffer1$ 'get the remaining bytes at the end
Get #2, start&, buffer2$ 'get the remaining bytes at the end
If buffer1$ <> buffer2$ Then
issame = False
End If
End If
Close
CompFile = issame
End Function
下一步的工作是寻找生成临时文件的方法,以及多点测试的连贯性,准确性问题。