Real Software Forums
http://forums.realsoftware.com/

How to copy file from one system to another?
http://forums.realsoftware.com/viewtopic.php?f=2&t=42739
Page 1 of 1

Author:  amitavak [ Fri Feb 17, 2012 10:11 am ]
Post subject:  How to copy file from one system to another?

Hi All,
Suppose I have two systems in same network, There are few files shared in system2, that can be access from system1 by run command. My application is running on system1. Can I copy that shared files from system2 to system1 through rb code?

Author:  Jason_Adams [ Fri Feb 17, 2012 10:21 am ]
Post subject:  Re: How to copy file from one system to another?

Sure!

Read the file on App1 via TextInputStream, temporarily store the string, send it via TCPSocket to App2, write a new file on App2 with said data, and you're good to go. :)

Author:  arthofer [ Fri Feb 17, 2012 10:34 am ]
Post subject:  Re: How to copy file from one system to another?

Hi there!

From your description, i assume you want to acess a file/folder shared via samba.

So there are two ways:

- Do it like mentioned before.
Read the file with a TextInputStream/BinaryStreamReader and send it via TCP.
I suggest you to build a small protocol that handles the request (say hello first, ask for a file, send the file, send a checksum, check the checksum, acknowledge that you recieved the file)
Also think of compression, depending on what data you want to send.
Another thing would be authentication/encryption. Depending on your purchased plugins and usage, this could be easy or hard to implement.

- Create a instance of a shell class and call something like sh.execute("copy \\System1\Share\File.txt \File.txt")

I personally would prefer #1

Author:  Jason_Adams [ Fri Feb 17, 2012 10:48 am ]
Post subject:  Re: How to copy file from one system to another?

arthofer wrote:
I suggest you to build a small protocol that handles the request (say hello first, ask for a file, send the file, send a checksum, check the checksum, acknowledge that you recieved the file)

Why would you include a checksum if you're using TCP which intrinsically has a a checksum?

Author:  Akiland [ Fri Feb 17, 2012 10:58 am ]
Post subject:  Re: How to copy file from one system to another?

You could throw up a shell and call rsync if it's available on both computers.

Author:  amitavak [ Mon Feb 20, 2012 2:08 am ]
Post subject:  Re: How to copy file from one system to another?

Quote:
Hi All,
Suppose I have two systems in same network, There are few files shared in system2, that can be access from system1 by run command. My application is running on system1. Can I copy that shared files from system2 to system1 through rb code?


I mean to say, "Run" command on Windows7. In "Run" command if I type "\\192.168.1.2", It listed the shared file of that specified system. Now how can I get that shared files through RB?

Author:  msssltd [ Mon Feb 20, 2012 9:00 am ]
Post subject:  Re: How to copy file from one system to another?

amitavak wrote:
In "Run" command if I type "\\192.168.1.2", It listed the shared file of that specified system. Now how can I get that shared files through RB?
You can use the FolderObject.CopyFileTo method, as documented in the Language Reference.

Network file system operations are handled by a 'redirector' integrated into the operating system. The redirector makes a remote file look like a local file to applications. You can then use the FolderItem class to interact with remote files in RB, as if they were local.

On Windows, a path of the style \\host_name\share_name\file_path is known as a UNC path. RB on Windows handles UNC paths, although I forget which path mode you have to use. There are a few gotchas but nothing too difficult.

Author:  AdamAnt [ Thu May 24, 2012 2:53 pm ]
Post subject:  Re: How to copy file from one system to another?

I am curious about a similar approach. Suppose I use the GetOpenFolderItem function to allow a user to get a local file, can I copy that file to another location on the same drive? i.e. get document and store it in a folder within the application support files.

How would I go about this if it is possible?

Author:  amitavak [ Fri May 25, 2012 12:35 am ]
Post subject:  Re: How to copy file from one system to another?

Do you want something like this...

Dim f As FolderItem
f = GetOpenFolderItem("*")

If f <> Nil Then
Dim DestinationFolder As FolderItem
DestinationFolder = GetFolderItem("D:\New Folder") //Provide your destination path here

If DestinationFolder.Exists And DestinationFolder.Directory Then
f.CopyFileTo(DestinationFolder)
End If

End If

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/