Re: files on external drives
Posted: Sun Mar 29, 2020 7:23 pm
Hi Templar
Sorry to hijack your thread for my problem.
Sorry to hijack your thread for my problem.
Exclusive forum for HMG, a Free / Open Source xBase WIN32/64 Bits / GUI Development System
http://hmgforum.com/
Nope, not corrupt, and I've tried it with several files....serge_girard wrote: ↑Sun Mar 29, 2020 4:33 pm Templar,
File is maybe corrupt?
Try another file.
Serge
Okay, here goes:
Code: Select all
For i=1 To 999
If Alias( i ) = "AUTHORS"
Msginfo ( "Alias 'Authors' is already open in " + str (i) + " work area.")
Endif
Next i
Code: Select all
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Lanmanworkstation\Parameters
Code: Select all
DirectoryCacheLifetime
FileNotFoundCacheLifetime
FileInfoCacheLifetime
Code: Select all
CLOSE ALL
cFILE1 := "C:\TEST\F0001.DBF"
cFile2 := "C:\TEST\F0001C.DBF"
cFile3 := "F:\TEST\F0001C.DBF"
cFile4 := "G:\TEST\F0001C.DBF"
cFile5 := "P:\TEST\F0001C.DBF"
cFile6 := "Q:\TEST\F0001C.DBF"
cFile7 := "Y:\TEST\F0001C.DBF"
cFile8 := "z:\TEST\F0001C.DBF"
COPY FILE &cFile1 TO &cFile2
COPY FILE &cFile1 TO &cFile3
COPY FILE &cFile1 TO &cFile4
COPY FILE &cFile1 TO &cFile5
COPY FILE &cFile1 TO &cFile6
COPY FILE &cFile1 TO &cFile7
COPY FILE &cFile1 TO &cFile8
IF FILE("&cFile2")
USE &cFile2 ALIAS C2 NEW
GO TOP
USE &cFile3 ALIAS C3 NEW
GO TOP
USE &cFile4 ALIAS C4 NEW
GO TOP
USE &cFile5 ALIAS C5 NEW
GO TOP
USE &cFile6 ALIAS C6 NEW
GO TOP
USE &cFile7 ALIAS C7 NEW
GO TOP
USE &cFile8 ALIAS C8 NEW
GO TOP
msginfo( "ALL ok" )
ELSE
msginfo( "No such file" )
ENDIF
Try this code:Templar wrote: ↑Tue Mar 31, 2020 9:40 am Yes but it is not open! Let me revise the sample:
1 CLOSE ALL
2 cFILE1:= "C:\BOOKS\AUTHORS.dbf"
3 cFile2:= "E:\BOOKS\AUTHORS.dbf"
4 COPY FILE &cFile1 TO &cFile2
5 IF FILE("&cFile2")
6 USE &cFile2
7 GO TOP
8 ELSE
9 ? "No such file" ; INKEY(0) ; RETURN
10 ENDIF
This will produce a runtime error, "Workarea not in use" at line 7
Templar
Code: Select all
#include "HMG.CH"
FUNCTION main()
Local cFile1:= "C:\BOOKS\AUTHORS.dbf"
Local cFile2:= "E:\BOOKS\AUTHORS.dbf"
Local nSuccess
CLOSE DATA
IF !File ( cFile1 )
MsgStop ( "File " + cFile1 + " doesn't exist", "Error" )
RETURN
ENDIF
IF !hb_DirExists ( hb_FNameDir ( cFile2 ) )
//Try to create folders structure
IF !hb_DirBuild(hb_FNameDir ( cFile2 ))
MsgStop ( "Error while creating folder " + hb_FNameDir ( cFile2 ), "Error" )
RETURN
ENDIF
ENDIF
IF ( nSuccess := hb_FCopy (cFile1 , cFile2) ) <> 0
MsgStop ( "Error #" + hb_ValToStr( nSuccess) + " while copying from " + cFile1 + " to " + cFile2, "Error" )
RETURN
ENDIF
IF !File ( cFile2 )
MsgStop ( "File " + cFile2 + " doesn't exist.", "Error" )
RETURN
ENDIF
IF hb_FSize( cFile1, .F. ) <> hb_FSize( cFile2, .F. )
MsgStop ( "The sizes of both files do not match", "Error" )
RETURN
ENDIF
USE &cFile2
DO WHILE NETERR()
IF !MsgRetryCancel("Error opening file. Try again?", "USE error")
MsgStop ("Canceled")
EXIT
ENDIF
USE &cFile2
ENDDO
IF Empty ( Alias() )
MsgStop ( 'The "USE" command failed.', "Failed")
RETURN
ENDIF
GO TOP
MsgInfo ("Successfully")
CLOSE DATA
RETURN