PDA

View Full Version : Copy file from HDD to docs folder


wedgea09
04-17-2006, 02:42 PM
I know that I can use HTTP.Download to copy from the web and place a file into my docs folder of my program. I want to be able to do the same from a LAN. Go to a folder on my network and copy a file from that folder to my docs folder.

TJS
04-18-2006, 07:35 AM
Your best bet would be to use the File.Install() action. It will accept UNC path as source or destination and has some nice extras.

wedgea09
04-18-2006, 07:55 AM
Here is the script I'm using with File.Install in place. It does the comparison part but when it comes to transferring the file to the docs folder its a no go.

ListBox.DeleteItem("ListBox1", LB_ALLITEMS)
size = File.GetSize("C:\\My Shared Folder\\full.wmv");
exist = File.DoesExist("Autoplay\\Docs\\full.wmv");
if exist == true then
size2 = File.GetSize("Autoplay\\Docs\\full.wmv");
if size ~= size2 then
ListBox.AddItem("ListBox1", "full.wmv", "")
StatusDlg.SetMessage("Downloading File.. Please be patient");
StatusDlg.SetTitle("Download In Progress");
StatusDlg.Show(MB_ICONNONE, false);
File.Install("C:\\My Shared Folder\\full.wmv", "Autoplay\\Docs\\full.wmv", FILE_INSTALL_ALWAYS, false, false);
StatusDlg.Hide();
end
end
if exist == false then
ListBox.AddItem("ListBox1", "full.wmv", "")
StatusDlg.SetMessage("Downloading File.. Please be patient");
StatusDlg.SetTitle("Download In Progress");
StatusDlg.Show(MB_ICONNONE, false);
File.Install("C:\\My Shared Folder\\full.wmv", "Autoplay\\Docs\\full.wmv", FILE_INSTALL_ALWAYS, false, false);
StatusDlg.Hide();
end

TJS
04-18-2006, 08:27 AM
Two things to try:

1) Add an error check after the File.Install() actions. This should tell you why nothing is happening.


err = Application.GetLastError;
if err ~= 0 then
Dialog.Message("Error " .. err, _tblErrorMessages[err]);
end



2) I'd recommend using the full path to the network resource instead of the "C:\\My Shared Folder\\full.wmv"

Something like:

"\\\\MyServerName\\ShareFolderName\\full.wmv"

or

"\\192.168.1.101\\ShareFolderName\\fill.wmv"

wedgea09
04-18-2006, 09:57 AM
No errors show up. But the problem isn't getting the source file it is getting the source file into the Autoplay\docs directory.

TJS
04-18-2006, 10:09 AM
A couple things you mentioned:

It does the comparison part but when it comes to transferring the file to the docs folder its a no go.
and
the problem isn't getting the source file it is getting the source file into the Autoplay\docs directory.

How did you come to these conclusions? Does the Progress Dialog Popup?

wedgea09
04-18-2006, 10:22 AM
Yes it is definitely a problem on the side of copying/installing the file into the Autoplay\Docs folder. If I specify the folder as being under f:\ , as is the case currently, I can get a transfer to my drive. Actually I forgot to put in my original post that this app is running on a usb flash drive and therefor the drive letter is not static. I need a way to identify the drive letter and have it automatically entered into the file.copy for the removable drive.

This works:
File.Copy("\\\\Guestbongo\\epubs\\E-Pubs.apz", "F:\\Autoplay\\Docs\\E-Pubs.apz", false, true, false);

This Doesn't
File.Copy("\\\\Guestbongo\\epubs\\E-Pubs.apz", "Autoplay\\Docs\\E-Pubs.apz", false, true, false)

Mina
04-18-2006, 11:40 AM
Try this
File.Copy("\\\\Guestbongo\\epubs\\E-Pubs.apz", _SourceDrive.."\\Autoplay\\Docs\\E-Pubs.apz", false, true, false)

wedgea09
04-18-2006, 04:04 PM
Thanks guys

This is what I ended up with.


tblDrives = Drive.Enumerate();
sDataDrive = "";
for n, DriveLetter in tblDrives do
nType = Drive.GetType(DriveLetter);
if nType == 2 then
sDataDrive = DriveLetter;
end
end
ListBox.DeleteItem("ListBox1", LB_ALLITEMS);
folder = Folder.DoesExist("\\\\Guestbongo\\epubs3\\");
if folder == true then
Dialog.Message("", "Downloading Updates From LAN", MB_OK)
size = File.GetSize("\\\\Guestbongo\\epubs3\\File compare download.zip");
exist = File.DoesExist(sDataDrive.."\\Autoplay\\Docs\\File compare download.zip");
if exist == true then
size2 = File.GetSize(sDataDrive.."\\Autoplay\\Docs\\File compare download.zip");
else if size ~= size2 then
ListBox.AddItem("ListBox1", "Network Existed", "")
StatusDlg.SetMessage("Downloading File.. Please be patient");
StatusDlg.SetTitle("Download In Progress");
StatusDlg.Show(MB_ICONNONE, false);
File.Copy("\\\\Guestbongo\\epubs3\\File compare download.zip", sDataDrive.."\\Autoplay\\Docs\\File compare download.zip", false, true, false);
StatusDlg.Hide();
end
end