I know this has been covered elsewhere in the forums on a couple of occasions but there has to be a simpler way, doesn’t there, or am I just having a mental block.
I am writing an addon for a legacy database system, files are stored on a server, and a database record is created in a MSACCESS database.
Going forward my system actually stores the file extension of the file ‘copied’ to the server so its easy, the legacy system does not.
Each time a file is copied, it is renamed to the document record ID (autoincrement record number) in the MSACCESS database, also saved at the same time is a .DAT file, basically a text file with some information in it related to the file. So for every document there are two documents, example
155552.dat
155552.?
I need to find the ? to launch the file, basically if this was a shell command, dir 155552.*, ignore the .DAT file and what is left is the file needed, grab the extension, add it to the rest of the file and launch the file.
Each of these folders broken down by year and month contains hundreds of files so the below iteration across all files is slow, is there a way to only search the two files and ignore the .DAT file, thus making it much quicker.
It is not complete code as i will search the array of files to launch the right one.
Any suggestions or pointers as always appreciated.
[code]
//launch double clicked file
dim f1 as FolderItem=getfolderitem(lbDocument.rowtag(lbdocument.listindex))
if f1<>nil and f1.exists then
f1.Launch
else
//old documents may not have extension recorded so need aditional check
//ignore .dat file - what is left
Dim myFolder As FolderItem
myfolder = getfolderitem(storagepath)
dim filelist() as string
If myFolder Is Nil Then
Return
End If
Dim filecount As Integer = myFolder.Count
For i As Integer = 1 To filecount
Dim f As FolderItem = myFolder.Item(i)
If f <> Nil and uppercase(f.type)<>".DAT" Then
filelist.Append(f.Name)
End If
Next
dim res as integer
res=msgbox(“The document associated with this”+EndOfLine+“record cannot be found to launch.”,16,“Document Image Error”)
end if[/code]