Re: File Rename failing with STATUS_OBJECT_NAME_INVALID...

Don’t believe the DOCs!
It is very limited, no a lot of details.

Try experiment and compare parameters as I described you…

Pay attention also, you will receive a bit different parameters for renaming inside directory and moving file from directory to other inside single volume. The last is impossible by “ren”, but may be done by Explorer.

As noted here Target FileObject on Rename has to be target directory, not target file. Probably it is your problem, but I forgot details, sorry, check it.

I had lost a lot of time to arrange Rename operation - it was one of the most difficult parts of my driver. Be success… :slight_smile:

Regards,
MG.

Subject: Re: File Rename failing with STATUS_OBJECT_NAME_INVALID.
From: Ashish Goyal
> Date: Tue, 2 Mar 2010 22:02:47 +0530
> X-Message-Number: 10
>
> I am not sure…According to docs, I am doing correct.
> “this member is a file object pointer for the parent directory of the file
> that is the target of the operation.”

>Pay attention also, you will receive a bit different parameters for renaming inside directory and moving

file from directory to other inside single volume. The last is impossible by “ren”, but may be done by
Explorer.

This is not a rename, but copy+delete.

MoveFile(Ex) API also cannot work this way.

Explorer has a heuristics. If the dst and src are no the same volume (in shell’s notion of “volume”) - then it uses MoveFile(Ex). Otherwise, it uses CopyFile(Ex)+delete of src.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

Maxim,
You are not right.
I’ve played with it a lot and know exactly how it works.:slight_smile:
Full algorithm is:

  1. Explore uses MoveFile(Ex), you correct here
  2. MoveFile works as “copy+delete” only for different volumes.
    For (suspected) same volumes it tries works as rename.
  3. But!!! If appropriate IRP_MJ_SET_INFORMATION (FileRenameInformation) returns STATUS_NOT_SAME_DEVICE, MoveFile generates “copy+delete” operation…

I guess this algorithm done for network support where not every time possible defining is it same volume by address in format \Server\Share.…

Regards,
MG.

Subject: Re: File Rename failing with STATUS_OBJECT_NAME_INVALID…
From: “Maxim S. Shatskih”
> Date: Wed, 3 Mar 2010 17:26:32 +0300
> X-Message-Number: 6
>
> >Pay attention also, you will receive a bit different parameters for > renaming inside directory and moving
> >file from directory to other inside single volume. The last is impossible > by “ren”, but may be done by
> >Explorer.
>
> This is not a rename, but copy+delete.
>
> MoveFile(Ex) API also cannot work this way.
>
> Explorer has a heuristics. If the dst and src are no the same volume (in > shell’s notion of “volume”) - then it uses MoveFile(Ex). Otherwise, it uses > CopyFile(Ex)+delete of src.
>
> –
> Maxim S. Shatskih
> Windows DDK MVP
> xxxxx@storagecraft.com
> http://www.storagecraft.com

>3. But!!! If appropriate IRP_MJ_SET_INFORMATION (FileRenameInformation) returns

STATUS_NOT_SAME_DEVICE, MoveFile generates “copy+delete” operation…

Thanks for correction.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com