DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

DataFileCopy in the same folder

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

  1. create temp folder (opt.)
  2. copy to temp folder
  3. rename in temp folder
  4. move back from temp folder
  5. remove temp folder (opt.)

In fact, this limitation makes no sense to me.

0 Kudos
Message 1 of 3
(2,333 Views)

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()

  

0 Kudos
Message 2 of 3
(2,269 Views)

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

Message 3 of 3
(2,265 Views)