Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Moving Directory using win32api::File

Reply
Thread Tools

Moving Directory using win32api::File

 
 
Brian
Guest
Posts: n/a
 
      04-21-2004
I am trying to move a directory that contains numerous other
subdirectories, e.g. c:\temp\source\temp1, temp2, to a new directory,
e.d. c:\test. Here is my script:

use Win32API::File qw( :ALL );
use strict;

my $source = "c:\\temp\\source";
my $destination = "c:\\test";
my $mvError = "";

MoveFileEx( $source, $destination, MOVEFILE_REPLACE_EXISTING() )
or die "Can't move $source to $destination: ",fileLastError(),"\n";

I get the following error:

Can't move c:\temp\source to c:\test\: Access is denied

Any ideas?

When I try: MoveFile( $source, $destination )

I get an error stating that the file already exists


 
Reply With Quote
 
 
 
 
Sisyphus
Guest
Posts: n/a
 
      04-22-2004
Brian wrote:
> I am trying to move a directory that contains numerous other
> subdirectories, e.g. c:\temp\source\temp1, temp2, to a new directory,
> e.d. c:\test. Here is my script:
>
> use Win32API::File qw( :ALL );
> use strict;
>
> my $source = "c:\\temp\\source";
> my $destination = "c:\\test";
> my $mvError = "";
>
> MoveFileEx( $source, $destination, MOVEFILE_REPLACE_EXISTING() )
> or die "Can't move $source to $destination: ",fileLastError(),"\n";
>
> I get the following error:
>
> Can't move c:\temp\source to c:\test\: Access is denied
>
> Any ideas?
>
> When I try: MoveFile( $source, $destination )
>
> I get an error stating that the file already exists
>
>


Just a guess:
You need administrator rights to delete files from C:\temp (which would
not be unusual if that is your $ENV{'TEMP'} directory) - which is why
you get the "Access is denied" message. Creating a copy, however, poses
no problem - so that part of MoveFileEx() succeeds.
I assume that the "file already exists" message (that you subsequently
get) is, in fact, correct ?

Cheers,
Rob

--
To reply by email u have to take out the u in kalinaubears.

 
Reply With Quote
 
 
 
 
Brian
Guest
Posts: n/a
 
      04-22-2004
Nope that is not it. I am logged on as administrator. As well, nothing
succeeds, there is no copy, nothing exists in destination directory. I
just think MoveFile displays a different error than MoveFileEx does for the
same condition.

I would be grateful for any other ideas.

Sisyphus wrote:

> Brian wrote:
> > I am trying to move a directory that contains numerous other
> > subdirectories, e.g. c:\temp\source\temp1, temp2, to a new directory,
> > e.d. c:\test. Here is my script:
> >
> > use Win32API::File qw( :ALL );
> > use strict;
> >
> > my $source = "c:\\temp\\source";
> > my $destination = "c:\\test";
> > my $mvError = "";
> >
> > MoveFileEx( $source, $destination, MOVEFILE_REPLACE_EXISTING() )
> > or die "Can't move $source to $destination: ",fileLastError(),"\n";
> >
> > I get the following error:
> >
> > Can't move c:\temp\source to c:\test\: Access is denied
> >
> > Any ideas?
> >
> > When I try: MoveFile( $source, $destination )
> >
> > I get an error stating that the file already exists
> >
> >

>
> Just a guess:
> You need administrator rights to delete files from C:\temp (which would
> not be unusual if that is your $ENV{'TEMP'} directory) - which is why
> you get the "Access is denied" message. Creating a copy, however, poses
> no problem - so that part of MoveFileEx() succeeds.
> I assume that the "file already exists" message (that you subsequently
> get) is, in fact, correct ?
>
> Cheers,
> Rob
>
> --
> To reply by email u have to take out the u in kalinaubears.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Free Moving Estimate, Local Movers, Long Distance Moving, PackingSupplies, Storage Rental, Home Moving, Apartment Moving, Office Moving,Commercial Moving linkswanted ASP .Net 0 01-06-2008 04:45 AM
Moving to California Moving to L.A linkswanted Digital Photography 3 01-05-2008 04:22 PM
movers los angeles moving storage services movers in L.A companymoving companies moving in calfornia los angeles linkswanted HTML 0 12-21-2007 10:55 PM
System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() are not returning the specified directory Nathan Sokalski ASP .Net 2 09-06-2007 03:58 PM



Advertisments