03-12-2020 10:51 AM
Dear all,
the DIAdem docu tells me about DataFileCopy():
"DIAdem specifies the name of the target file from the name of the source file. Therefore the FSTargetPath variable must not contain a filename."
Is there a more elegant way of creating a second copy of a data file with different name in the same folder than
In fact, this limitation makes no sense to me.
03-18-2020 01:14 AM
You are correct, the 2nd parameter for DataFileCopy() expects a path, not a path with a filename. Use FileCopy instead.
Dim sFilePathSrc, sFilePathDest
sFilePathsrc=sFilePathDIAdemExample("Example.tdm")
Call LogFileWrite("sFilePathsrc='" & sFilePathSrc & "'")
sFilePathDest = NameSplit(sFilePathSrc,"P") & "NewFilename." & NameSplit(sFilePathSrc,"E")
Call LogFileWrite("sFilePathDest = '" & sFilePathDest & "'")
Call FileCopy(sFilePathSrc, sFilePathDest, True)
Call LogFileWrite("FileExist() = " & FileExist(sFilePathDest))
Function sFilePathDIAdemExample(ByVal sFilename)
'Returns the full absolute file/path for the location of the DIAdem
'example (TDM/TDMS) file sFilename. Looks in the usual places.
'Returns "" if the file cannot be found.
'v20191119
sFilePathDIAdemExample = ""
Dim arrFilePaths, sFilePath, sFolder: ReDim arrFolders(2): arrFolders(0) = ProgramDrv: arrFolders(1) = CommonDocumentsPath: arrFolders(2) = GetEnv("PUBLIC")
For Each sFolder In arrFolders
arrFilePaths = DirListGet(sFolder,sFilename,"Date/Time","FullFilenamesRecursive")
If IsArray(arrFilePaths) Then
For Each sFilePath In arrFilePaths
If InStr(1,sFilePath,"Libr",vbTextCompare) = 0 Then sFilePathDIAdemExample = sFilePath: Exit For
Next
End If
If Len(sFilePathDIAdemExample) > 0 Then Exit For
Next
If IsArray(arrFilePaths) Then Call Erase(arrFilePaths)
If IsArray(arrFolders) Then Call Erase(arrFolders)
End Function 'sFilePathDIAdemExample()
03-18-2020 02:45 AM
Hi, markwkiehl!
Nope, FileCopy() does not deal with the links to binaries (*.tdx) like DataFileCopy() does (which is the reason for DataFileCopy(), I guess).
Ciao
Volker