Discussion:
Copy File to other PC
Laurent
2002-12-10 10:01:21 UTC
Permalink
Hi,

How can I copy a File to another computer in the network?
Especially, how should the second parameter in the function
CopyFile look like?

Regards,
Laurent.


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/CBxunD/vN2EAA/xGHJAA/i7folB/TM
---------------------------------------------------------------------~->

The Delphi Collection Web Site!
http://www.delphicollection.com/public/index.shtml
---------------------------------------------------------------
Unsubscribe:delphi-programming-***@yahoogroups.com
List owner:delphi-programming-***@yahoogroups.com
---------------------------------------------------------------

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Jatin N. Bhoir
2002-12-10 10:36:43 UTC
Permalink
Post by Laurent
How can I copy a File to another computer in the network?
Especially, how should the second parameter in the function
CopyFile look like?
Help on CopyFile function cannot be found in Delphi Help. Instead you can
search help for CopyFile in Windows SDK. If ever you need to see an example
of WinAPI calls, search through VCL Source Code (if u have it !!) with the
necessary keyword. VCL Source Code is the best way to learn from Borland
themselves. Thats what source code is for :-)

{WinAPI}
BOOL CopyFile(
LPCTSTR lpExistingFileName, // pointer to name of an existing file
LPCTSTR lpNewFileName, // pointer to filename to copy to
BOOL bFailIfExists // flag for operation if file exists
);
{/WinAPI}

{Delphi}
CopyFile(PChar(Source), PChar(Destination), true)
{/Delphi}

You can also try looking for help on CopyFileEx with some extended flags.

Warm regards,
Jatin


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/CBxunD/vN2EAA/xGHJAA/i7folB/TM
---------------------------------------------------------------------~->

The Delphi Collection Web Site!
http://www.delphicollection.com/public/index.shtml
---------------------------------------------------------------
Unsubscribe:delphi-programming-***@yahoogroups.com
List owner:delphi-programming-***@yahoogroups.com
---------------------------------------------------------------

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Laurent
2002-12-10 11:55:54 UTC
Permalink
Hi,

Thanks for the response, but I did already now al that.
What I need to know is how to write the second param (destination).

If you copy to a location on the pc, it will be sDest := 'C:\MyDir',
but what if the file must be copied to a another pc.
sDest := 'PC1:\MyDir' will not work!
sDest := '\\PC1\MyDir' neither ...

Laurent.
Post by Jatin N. Bhoir
Post by Laurent
How can I copy a File to another computer in the network?
Especially, how should the second parameter in the function
CopyFile look like?
Help on CopyFile function cannot be found in Delphi Help. Instead you can
search help for CopyFile in Windows SDK. If ever you need to see an example
of WinAPI calls, search through VCL Source Code (if u have it !!) with the
necessary keyword. VCL Source Code is the best way to learn from Borland
themselves. Thats what source code is for :-)
{WinAPI}
BOOL CopyFile(
LPCTSTR lpExistingFileName, // pointer to name of an existing file
LPCTSTR lpNewFileName, // pointer to filename to copy to
BOOL bFailIfExists // flag for operation if file exists
);
{/WinAPI}
{Delphi}
CopyFile(PChar(Source), PChar(Destination), true)
{/Delphi}
You can also try looking for help on CopyFileEx with some extended flags.
Warm regards,
Jatin
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/CBxunD/vN2EAA/xGHJAA/i7folB/TM
---------------------------------------------------------------------~->

The Delphi Collection Web Site!
http://www.delphicollection.com/public/index.shtml
---------------------------------------------------------------
Unsubscribe:delphi-programming-***@yahoogroups.com
List owner:delphi-programming-***@yahoogroups.com
---------------------------------------------------------------

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Jatin N. Bhoir
2002-12-10 12:15:02 UTC
Permalink
Hi Laurent,

{Delphi}
CopyFile(PChar('C:\WINNT\Clock.AVI'), PChar('\\DbServer\Music\Clock.AVI'),
False);
{/Delphi}

This one works just perfectly fine !!
Are your trying to copy directories / folders ??

Use CopyFolder instead..

{WinAPI}
HRESULT CopyFolder(ULONG cbEntryID, LPENTRYID lpEntryID, LPCIID lpInterface,
LPVOID lpDestFolder, LPTSTR lpszNewFolderName, ULONG ulUIParam,
LPMAPIPROGRESS lpProgress, ULONG ulFlags)
{/WinAPI}

Jatin
Post by Laurent
Hi,
Thanks for the response, but I did already now al that.
What I need to know is how to write the second param (destination).
If you copy to a location on the pc, it will be sDest := 'C:\MyDir',
but what if the file must be copied to a another pc.
sDest := 'PC1:\MyDir' will not work!
sDest := '\\PC1\MyDir' neither ...
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/CBxunD/vN2EAA/xGHJAA/i7folB/TM
---------------------------------------------------------------------~->

The Delphi Collection Web Site!
http://www.delphicollection.com/public/index.shtml
---------------------------------------------------------------
Unsubscribe:delphi-programming-***@yahoogroups.com
List owner:delphi-programming-***@yahoogroups.com
---------------------------------------------------------------

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Christian Gütter
2002-12-10 12:03:56 UTC
Permalink
Hi Laurent,
Post by Laurent
If you copy to a location on the pc, it will be sDest := 'C:\MyDir',
but what if the file must be copied to a another pc.
sDest := 'PC1:\MyDir' will not work!
sDest := '\\PC1\MyDir' neither ...
you have to do it the following way:

sDest := '\\PC1\MyDir\Filename.EXT

Windows needs to know the filename of the
destination file.


Cheers,
Christian

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/CBxunD/vN2EAA/xGHJAA/i7folB/TM
---------------------------------------------------------------------~->

The Delphi Collection Web Site!
http://www.delphicollection.com/public/index.shtml
---------------------------------------------------------------
Unsubscribe:delphi-programming-***@yahoogroups.com
List owner:delphi-programming-***@yahoogroups.com
---------------------------------------------------------------

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
p***@aucxistrading.com
2002-12-10 12:12:11 UTC
Permalink
Hi,

I think \\pc1\mydir will work, but MyDir is a sharename and not a
directoryname.

Regards,
Peter

-----Oorspronkelijk bericht-----
Van: Christian Gütter [mailto:***@pgpa.de]
Verzonden: dinsdag 10 december 2002 13:04
Aan: delphi-***@yahoogroups.com
Onderwerp: Re: [Delphi] Copy File to other PC


Hi Laurent,
Post by Laurent
If you copy to a location on the pc, it will be sDest := 'C:\MyDir',
but what if the file must be copied to a another pc.
sDest := 'PC1:\MyDir' will not work!
sDest := '\\PC1\MyDir' neither ...
you have to do it the following way:

sDest := '\\PC1\MyDir\Filename.EXT

Windows needs to know the filename of the
destination file.


Cheers,
Christian


The Delphi Collection Web Site!
http://www.delphicollection.com/public/index.shtml
---------------------------------------------------------------
Unsubscribe:delphi-programming-***@yahoogroups.com
List owner:delphi-programming-***@yahoogroups.com
---------------------------------------------------------------

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/CBxunD/vN2EAA/xGHJAA/i7folB/TM
---------------------------------------------------------------------~->

The Delphi Collection Web Site!
http://www.delphicollection.com/public/index.shtml
---------------------------------------------------------------
Unsubscribe:delphi-programming-***@yahoogroups.com
List owner:delphi-programming-***@yahoogroups.com
---------------------------------------------------------------

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Laurent
2002-12-10 12:35:35 UTC
Permalink
Thanks to all for the responses. It works.
Only try to copy some files; no folders.

Reagrds,
Laurent.
Post by Christian Gütter
Hi Laurent,
{Delphi}
CopyFile(PChar('C:\WINNT\Clock.AVI'), PChar
('\\DbServer\Music\Clock.AVI'),
Post by Christian Gütter
False);
{/Delphi}
This one works just perfectly fine !!
Are your trying to copy directories / folders ??
Use CopyFolder instead..
{WinAPI}
HRESULT CopyFolder(ULONG cbEntryID, LPENTRYID lpEntryID, LPCIID
lpInterface,
Post by Christian Gütter
LPVOID lpDestFolder, LPTSTR lpszNewFolderName, ULONG ulUIParam,
LPMAPIPROGRESS lpProgress, ULONG ulFlags)
{/WinAPI}
Jatin
Post by Laurent
Hi,
Thanks for the response, but I did already now al that.
What I need to know is how to write the second param
(destination).
Post by Christian Gütter
Post by Laurent
If you copy to a location on the pc, it will be
sDest := 'C:\MyDir',
Post by Christian Gütter
Post by Laurent
but what if the file must be copied to a another pc.
sDest := 'PC1:\MyDir' will not work!
sDest := '\\PC1\MyDir' neither ...
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/CBxunD/vN2EAA/xGHJAA/i7folB/TM
---------------------------------------------------------------------~->

The Delphi Collection Web Site!
http://www.delphicollection.com/public/index.shtml
---------------------------------------------------------------
Unsubscribe:delphi-programming-***@yahoogroups.com
List owner:delphi-programming-***@yahoogroups.com
---------------------------------------------------------------

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Sean & Teri Worle
2002-12-11 02:00:35 UTC
Permalink
Post by Laurent
How can I copy a File to another computer in the network?
Especially, how should the second parameter in the function
CopyFile look like?
From your message, I take it that you understand how CopyFile works, you
just need to know how to apply it to another PC.
The second parameter should be the destination file name. In this case,
this will be a UNC path. This will look somthing like this:
\\ComputerName\ShareName\Filename.extention
For example:
\\BobsBox\Common\blah.txt
In order for this to work, several things must be true. First of all, the
other computer must be on the network, and be accessable from your computer.
Secondly, they must have a shared folder (or drive) on that computer, and
finally, they must have given you write access to this share. Oh, and of
course the computer must be turned on. None of these conditions can be done
programmatically from your computer, for security reasons they must all be
done manually on the other computer.


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/CBxunD/vN2EAA/xGHJAA/i7folB/TM
---------------------------------------------------------------------~->

The Delphi Collection Web Site!
http://www.delphicollection.com/public/index.shtml
---------------------------------------------------------------
Unsubscribe:delphi-programming-***@yahoogroups.com
List owner:delphi-programming-***@yahoogroups.com
---------------------------------------------------------------

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Continue reading on narkive:
Loading...