Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Wed Dec 11, 2019 4:31 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: How to copy file from one system to another?
PostPosted: Fri Feb 17, 2012 10:11 am 
Offline
User avatar

Joined: Mon Jan 02, 2012 1:51 am
Posts: 382
Location: India
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?

_________________
Amitava Karan
Real Studio 2012 Release 1
Windows 7 (32 bit)
Mac OS X Version 10.7


Top
 Profile  
Reply with quote  
 Post subject: Re: How to copy file from one system to another?
PostPosted: Fri Feb 17, 2012 10:21 am 
Offline
User avatar

Joined: Fri Nov 10, 2006 4:10 pm
Posts: 1855
Location: Michigan, USA
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. :)

_________________
Windows 8 x64
Windows XP Pro SP3
Ubuntu 11.04 via Virtual Box
RS Enterprise 2012r1.1

Programming Tutorials & Free Projects: http://www.JasonTheAdams.com
"Christianity has not been tried and found wanting; it has been found difficult and not tried." - G.K. Chesterton


Top
 Profile  
Reply with quote  
 Post subject: Re: How to copy file from one system to another?
PostPosted: Fri Feb 17, 2012 10:34 am 
Offline

Joined: Tue Feb 14, 2012 5:39 am
Posts: 99
Location: Austria
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


Top
 Profile  
Reply with quote  
 Post subject: Re: How to copy file from one system to another?
PostPosted: Fri Feb 17, 2012 10:48 am 
Offline
User avatar

Joined: Fri Nov 10, 2006 4:10 pm
Posts: 1855
Location: Michigan, USA
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?

_________________
Windows 8 x64
Windows XP Pro SP3
Ubuntu 11.04 via Virtual Box
RS Enterprise 2012r1.1

Programming Tutorials & Free Projects: http://www.JasonTheAdams.com
"Christianity has not been tried and found wanting; it has been found difficult and not tried." - G.K. Chesterton


Top
 Profile  
Reply with quote  
 Post subject: Re: How to copy file from one system to another?
PostPosted: Fri Feb 17, 2012 10:58 am 
Offline
User avatar

Joined: Tue Jan 04, 2011 3:02 am
Posts: 1236
Location: Jönköping, Sweden
You could throw up a shell and call rsync if it's available on both computers.

_________________
Image http://www.linkedin.com/in/albinkiland
Dev. iMac 27" + 2x22" LG (2.8GHz Intel Core i7, 12GB RAM, 120GB SSD) OS X 10.8
Xojo Pro 2013r1


Top
 Profile  
Reply with quote  
 Post subject: Re: How to copy file from one system to another?
PostPosted: Mon Feb 20, 2012 2:08 am 
Offline
User avatar

Joined: Mon Jan 02, 2012 1:51 am
Posts: 382
Location: India
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?

_________________
Amitava Karan
Real Studio 2012 Release 1
Windows 7 (32 bit)
Mac OS X Version 10.7


Top
 Profile  
Reply with quote  
 Post subject: Re: How to copy file from one system to another?
PostPosted: Mon Feb 20, 2012 9:00 am 
Offline
User avatar

Joined: Fri Oct 28, 2005 7:05 am
Posts: 565
Location: Emsworth, UK
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.

_________________
Yes it's me in the avatar


Top
 Profile  
Reply with quote  
 Post subject: Re: How to copy file from one system to another?
PostPosted: Thu May 24, 2012 2:53 pm 
Offline

Joined: Mon May 21, 2012 4:42 pm
Posts: 10
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?


Top
 Profile  
Reply with quote  
 Post subject: Re: How to copy file from one system to another?
PostPosted: Fri May 25, 2012 12:35 am 
Offline
User avatar

Joined: Mon Jan 02, 2012 1:51 am
Posts: 382
Location: India
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

_________________
Amitava Karan
Real Studio 2012 Release 1
Windows 7 (32 bit)
Mac OS X Version 10.7


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group