PowerBASIC Users Meeting Point
The FILECOPY command - Printable Version

+- PowerBASIC Users Meeting Point (http://pump.richheimer.de)
+-- Forum: User to User Discussions (http://pump.richheimer.de/forumdisplay.php?fid=3)
+--- Forum: PowerBASIC for Windows (http://pump.richheimer.de/forumdisplay.php?fid=4)
+--- Thread: The FILECOPY command (/showthread.php?tid=52)



The FILECOPY command - Tillmann Viefhaus - 06-15-2025

When I write:

CHDR "D:\Test_with_Files"

A = "Original.exe"
B = "Original_Copy.exe"
Filecopy A, B

A is existing on the harddrive but File B is not created. Why is that?


RE: The FILECOPY command - Albert Richheimer - 06-15-2025

(06-15-2025, 05:04 PM)Tillmann Viefhaus Wrote: When I write:

CHDR "D:\Test_with_Files"

A = "Original.exe"
B = "Original_Copy.exe"
Filecopy A, B

A is existing on the harddrive but File B is not created. Why is that?

What does ERR say? This might give a clue.


RE: The FILECOPY command - Tillmann Viefhaus - 06-15-2025

(06-15-2025, 06:00 PM)Albert Richheimer Wrote:
(06-15-2025, 05:04 PM)Tillmann Viefhaus Wrote: When I write:

CHDR "D:\Test_with_Files"

A = "Original.exe"
B = "Original_Copy.exe"
Filecopy A, B

A is existing on the harddrive but File B is not created. Why is that?

What does ERR say? This might give a clue.
There is no ERR message. And thats whats suspicious. The command just doesn't work. Or does it write the new file elsewhere on the drive?

(06-15-2025, 06:21 PM)Tillmann Viefhaus Wrote:
(06-15-2025, 06:00 PM)Albert Richheimer Wrote:
(06-15-2025, 05:04 PM)Tillmann Viefhaus Wrote: When I write:

CHDR "D:\Test_with_Files"

A = "Original.exe"
B = "Original_Copy.exe"
Filecopy A, B

A is existing on the harddrive but File B is not created. Why is that?

What does ERR say? This might give a clue.
There is no ERR message. And thats whats suspicious. The command just doesn't work. Or does it write the new file elsewhere on the drive?
I found the error. I just had the wrong filename which was the one of the program I was working with. The file A used in FILECOPY must never contain the name or parts of the name of a programm which is just running.


RE: The FILECOPY command - Albert Richheimer - 06-15-2025

(06-15-2025, 06:21 PM)Tillmann Viefhaus Wrote: I found the error. I just had the wrong filename which was the one of the program I was working with. The file A used in FILECOPY must never contain the name or parts of the name of a programm which is just running.

No. The running program only has a write lock applied. I still can be read – what PB's filecopy is doing.

I just have tested it:

Code:
#compile exe
#dim all

function pbmain () as long
    local sFileA as string
    local sFileB as string
    sFileA = "test.exe"    ' This running program
    sFileB = "copy_of_test.exe"
    filecopy sFileA,sFileB
    if err then
       stderr str$(err)+": "+error$(err)
    end if
    if isfile(sFileB)=0 then
       stderr "Filecopy did not succeed."
    end if
end function

The filecopy is doing fine.


RE: The FILECOPY command - Dale Yarker - 06-16-2025

'Question is in PowerBASIC for Windows section, so changed Albert's code
'to PBWin from PBCC.
'
'I was curious if FileA is itself the running EXE containing FILECOPY.
'But that works fine also. (see #COMPILE line)
'
Code:
#compile exe "test.exe"
#dim all
'
function pbmain () as long
    local sFileA as string
    local sFileB as string
    sFileA = "test.exe"    ' This running program
    sFileB = "copy_of_test.exe"
    filecopy sFileA,sFileB
    if err then
      'stderr str$(err)+": "+error$(err)
      ? str$(err)+": "+error$(err)
    end if
    if isfile(sFileB)=0 then
      'stderr "Filecopy did not succeed."
      ? "Filecopy did not succeed."
    end if
    ? "done"
end function '
'that leaves CHDR "D:\Test_with_Files"
'1. is the program that is doing the FILECOPY in D:\Test_with_Files ?
'2. if FileA is not in D:\Test_with_Files it will not be found by FILECOPY.
'
'code in post 1 had no error checking and PB does not display "messages"
'unless asked.
'
'Cheers,