One possibility: this is from the MSDN site
"The one caveat is that the MoveFile function will fail on directory moves
when the destination is on a different volume."
Another possibility could be what platform you are running on in terms of
the size of the path and file name. On Win9x machines you are limited by
MAX_PATH (usually 255), on NT machines you can use the Unicode version to
get up to 32000 bytes for the path and file name. See the MSDN documentation
for more info.
Another possibility: is the rename not happening at all? What I mean is,
when defining your external function, use a datatype of long, instead of
boolean. The API returns zero for failure, and not zero for success, which
may not be what powerbuilder expects. You can also try using GetLastError()
to see what error occurs.
If you are feeling really ambitious you can jettison the problematic
MoveFile function and use the much nicer SHFileOperation() function. You
won't find documentation on the MSDN site for it (although it may be there,
I just haven't found it yet.) But at http://www.mvps.org/vbnet/ you will
find the Visual Basic description on how to use the function - among others
- (you will have to dig around a bit)
BTW, that is the API call that Windows Explorer uses for it's file
move/copy/delete/rename functionality. It's really sweet, fully
customizable, and if you want you can have that 'wonderful' dialogue with
the flying pieces of paper show up. It works the same on NT as 9x. The only
problem I have found is finding documentation.
Good luck
Sheldon Funk
> -----Original Message-----
> From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, March 17, 2000 9:27 AM
> To: [EMAIL PROTECTED]
> Subject: PFCSIG MoveFileA
>
> Greetings:
>
> I am trying to rename a file and I get an error . These are the
> steps I have done. This app is not using PFC
>
> 1)I created a local external function
>
> Function boolean MoveFileA (ref string oldfile, ref string newfile)
> library "KERNEL32.DLL"
>
> 2)I created a method in a userobject called of_rename and I have this
> fucntion call.
>
> MoveFileA(as_SourceFile, as_TargetFile)
> Here is the problem "MoveFileA returns FALSE".
>
> 3)as_sourcefile parameter and the as_TargetFile are all qualified with the
> path and the filename.
>
> The only thing I am thinking is the app is run on the network drive and
> the file I am trying to rename is in my local drive. But I dont think it
> should be a problem.
> Now in my other PFC app I am renaming a file and it works great. What am I
> missing??
>
> TIA
> JOsh
>
>
> > [EMAIL PROTECTED] HOSTED BY IIGG, INC. FOR HELP WITH LIST SERVE COMMANDS,
> ADDRESS
> > A MESSAGE TO [EMAIL PROTECTED] WITH THE FOLLOWING MESSAGE: help
> pfcsig
> > SEND ALL OTHER INQUIRES TO [EMAIL PROTECTED]
> [EMAIL PROTECTED] HOSTED BY IIGG, INC. FOR HELP WITH LIST SERVE COMMANDS, ADDRESS
> A MESSAGE TO [EMAIL PROTECTED] WITH THE FOLLOWING MESSAGE: help pfcsig
> SEND ALL OTHER INQUIRES TO [EMAIL PROTECTED]