PDA

View Full Version : File.Copy



John_Klassek
11-05-2003, 10:26 PM
Where is the error?

Can you tell me why the first five lines using File.Copy don't work?

I have also attached a screen capture as well.

File.Copy("Setup\\ClassicIT\\1024boats.bmp", _WindowsFolder, true, true, false, true, nil);
File.Copy("Setup\\ClassicIT\\1024avon.bmp", _WindowsFolder, true, true, false, true, nil);
File.Copy("Setup\\ClassicIT\\classic.exe", _WindowsFolder, true, true, false, true, nil);
File.Copy("Setup\\ClassicIT\\OEM*.*", _WindowsFolder .. "\\System32\\", true, true, false, true, nil);
File.Copy("Setup\\ClassicIT\\OEM*.*", _WindowsFolder .. "\\System\\", true, true, false, true, nil);
File.Run("Setup\\screensav\\ClassicSCR.EXE", "", "", SW_SHOWNORMAL, true);
Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
File.Open("Setup\\ClassicIT\\citslogo.reg", "", SW_SHOWNORMAL);
File.Open("Setup\\ClassicIT\\CitsURL.reg", "", SW_SHOWNORMAL);

Thanks for your help.

Regards,

John

Corey
11-05-2003, 10:53 PM
Hi John. Setup\\ClassicIT\\1024boats.bmp isn't a valid file path because it lacks a drive assigment... I think this is the issue. I believe if you edit that to be a full file path it will work. Let me know.:)

Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)

John_Klassek
11-05-2003, 11:57 PM
Hi Corey,

I've placed the Setup folder alongside the AutoPlay folder, rather than being in a subfolder. Thus the source path is created from the browse option within APMS5

Note that the others in that list, eg:

File.Run("Setup\\screensav\\ClassicSCR.EXE", "", "", SW_SHOWNORMAL, true);

works fine as a relative path.

I know that this is not File.Copy but File.Run - but I can't see why the difference?

The drive letter assignment for the installer has to remain relative; whether on CD or USB HDD, the default drive letter is automatically assigned by Windows.

I'm sure this is a bug? :)

Thanks for your help.

John

Corey
11-06-2003, 12:13 AM
HI John. OK humor me for a sec, try it with _SourceFolder instead and let me know, i.e.:

File.Copy(_SourceFolder.."Setup\\ClassicIT\\1024boats.bmp", _WindowsFolder, true, true, false, true, nil);

I think that will work. As for the File.Run this is because that program runs on your system without full path from the start menu > run field. For example if I type "calc.exe" into my run field it runs windows calculator, I don't have to type the full path. Know what I mean? Strictly speaking you should use a full path here too BTW. :) As you see for both actions in the help file it says the first argument required by each function is a string containing, "The path to [...]".

It's worth noting the subtle difference between File.Run (Same as typing something into Windows start menu > run field) and File.Open (Same as double clicking on the file in Windows Explorer).

As for making links relative, no problem use the built in variables (listed in the help file) such as _SourceFolder or create your own custom path variables at startup... Hope that helps. :)

Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)

Lorne
11-06-2003, 12:31 AM
Are you logged in with write access to the windows and system folders?

John_Klassek
11-06-2003, 01:00 AM
Corey, no the _SourceFolder option doesn't work either.

(And yes, logged in as Administrator with write access to all files and folders. I had no problem with this in APMS4).

Thanks again.

John

PS I've attached a screen capture of the directory structure, with the Setup folder outside of the AutoPlay folder, both of which are in the CD_ROOT folder.

PPS I'm looking forward to finding out what's causing this...

John_Klassek
11-06-2003, 01:18 AM
Hi Corey,

What I've discovered is that the following works:

File.Copy("AutoPlay\\ClassicIT\\1024boats.bmp", _WindowsFolder, true, true, false, true, nil);

However, there are two things that are apparent here.

The "wizard" in APMS5 automatically copies the image into "AutoPlay\\Images\\1024boats.bmp"

Now for technical reasons, I don't want the image stored in APMS5's default folder, so I manually re-type in \\ClassicIT\\ again as the original folder.

This works fine (incidentally without the need for _SourceFolder to be specified).

However, when copying from "Setup\\ClassicIT\\1024boats.bmp", a folder also in the root directory, the File.Copy fails.

I think we've found a bug in an otherwise excellent program.

Cheers,

John

Corey
11-06-2003, 01:38 AM
Hmmm, OK, shouldn't have doubted you. :) You have been extremely helpful in searching out and squashing stuff, our gratitude as always John, you're a Klass act. :)

Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)

John_Klassek
11-06-2003, 06:23 AM
Corey/Lorne,

I've been testing the File.Copy in a variety of scenarios.

The following instance works, when not accompanied by any File.Copy instances:

File.Copy("Setup\\ClassicIT\\avon1024.jpg", "F:\\Temp\\aaawww\\", true, true, false, true, nil);


However, this doesn't work:

File.Copy("Setup\\ClassicIT\\1024*.bmp", _WindowsFolder, true, true, false, true, nil);


Neither work in the case where I have multiple File.Copy instances, such as:

File.Copy("Setup\\ClassicIT\\1024*.bmp", _WindowsFolder, true, true, false, true, nil);
File.Copy("Setup\\ClassicIT\\1024*.bmp", "F:\\Temp\\aaawww", true, true, false, true, nil);


I'm beginning to think that the issue isn't with locating the source file/folder. The difficulty is locating the _WindowsFolder and because of that when there are multiple File.Copy requests, nothing gets copied.

Hope this information is helpful.

Regards,

John

Brett
11-06-2003, 06:30 AM
John,

Thanks for all of the research and reports. I will look into this today, find the bug and terminate it.

Brett
11-06-2003, 10:41 AM
John,

I fixed that bug in the code today. For now, you will need to use:

File.Copy(_SourceFolder.."\\Setup\\ClassicIT\\1024boats.bmp", _WindowsFolder, true, true, false, true, nil);

Note that this differs from Corey's code by the \\ in front of Setup\\ClassicIT\\1024boats.bmp. This should work for sure. Next release you will be able to do the relative path thing with no troubles.

John_Klassek
11-06-2003, 08:33 PM
Thanks Brett.

Yes, this now works!

Sure appreciate your looking into this.

Kind regards,

John