These forums are read-only and considered to be an archive. Please use the new Community for future interaction and posts.

Copying folders

Hi,

I encountered a problem while implementing the filevistacontrol. I got it all to work except the copying of folders. I got the filevistacontrol hooked up on a database and on every action there is an action performed on the database aswell.

Say i got the following structure on my filesystem:
-root
 - folder1 (child of root)
  -folder2 (child of folder1)
 -anotherfolder (child of root)

Now when i copy folder2 and past it back in folder1 i get the following:
root
 - folder1 (child of root)
  -folder2 (child of folder1)
  -folder2 (2)
 -anotherfolder (child of root)

Now when a folder gets copied the event 'Copied' of the filevistacontrol is called. This event makes the changes which are done on the filesystem in my database.
My functions looks as follows:

   private static void FileVistaControl_Copied(object sender, FileVistaCopiedEventArgs e)
        {
            ContentFileLogic fileLogic = new ContentFileLogic();

            string destFolder = e.RelativePath;
            string destRoot = e.RootFolder.Name;

            foreach (var name in e.ItemNames)
            {
                ContentDirectoryBO contentDirectory = GetDirectory(e.FromRelativePath, e.FromRootFolder.Name);
                if (contentDirectory != null)
                {
                    ContentFileBO file = fileLogic.GetContentFile(name, contentDirectory);
                    if (file != null)
                    {
                        ContentDirectoryBO newDirectory = GetDirectory(e.RelativePath, e.RootFolder.Name);
                        if (newDirectory != null)
                        {
                           //some functionality to insert a new file
                        }
                    }
                    else
                    {
                        //some functionality to insert a new folder
                    }
                }
            }
        }

The problem is that the name in e.ItemNames is Folder2 whereas the real name is Folder2 (2). Is there a way to get the right foldername cause this messes up the database...

Kind regards,

Gerard


Gerard 7/14/2010 7:43 AM
Hi Gerard,
I have sent you a fix via email which includes a solution to this problem.
There is now a new property named TargetItemNames for FileVistaCopiedEventArgs, so you can access the target name of the copied items with e.TargetItemNames array. Note that e.ItemNames still contains the original (source) file names.
Cem Alacayir 7/23/2010 6:49 AM