Trick to Rename Folder Using SPFolder (Sharepoint 2003)

at
Folder(s) in the Sharepoint v2 is an odd entity. Unlike others, it is not derived from the "List" base like Files. In other word, many standard features is not avaliable for it; and renaming is one of them. instead of rename the folder, Microsoft create a new folder, then moved all the contents within to the new folder, and then delete the old folder. This is done by the method of "moveto".

So when try to do the rename, instead of
SPFolder.Name = "NewFolderName";

we will use the code of
SPFolder.Moveto("NewFolderName");

to rename the file, try
SPFile.item["BaseName"] = "NewFileName";


======================
Keywords: SPFolder, SPFile, Rename File, Rename Folder

1 comment:

Sachin Kainth said...

I haven't figured out why these days the titles on pages with usefull information (this is such a page) have a link back to the same article/page. What possible purpose could this have?