November Happy Hour will be moved to Thursday December 5th.

Copy files between VirtualPathVersioningProviders

Vote:
 

I have a VirtualPathVersioningProvider for documents and one for pages. My old migrated workroom files is now converted to versioning files and directorys. In the new templates the workroom files is located in the workroom startpage folder. So i would like to  copy the files between those to places. 

Ihave tried this but does not work for me.

http://world.episerver.com/modules/forum/pages/thread.aspx?id=30791

This is what i tried ...

VirtualDirectory oldvd = VirtualPathHandler.PageFolderProvider.GetDirectory(oldFileDir);

string newVirtualPath = VirtualPathUtilityEx.Combine(pageDirectoryRootVirtualPath, folderId.ToString());

bool doesDirExist = HostingEnvironment.VirtualPathProvider.DirectoryExists(newVirtualPath);
bool doesOldDirExist = HostingEnvironment.VirtualPathProvider.DirectoryExists(oldFileDir);

foldersLiteral.Text += oldvd.Name + ", <br />";
VirtualDirectory newVd = null;
if (doesDirExist)
{
foldersLiteral.Text += folderId + ", <br /> does exist!<br><br>";
newVd = VirtualPathHandler.Instance.GetDirectory(newVirtualPath, true) as VersioningDirectory;
     }
else {
newVd = VersioningDirectory.CreateDirectory(newVirtualPath);
}

VersioningDirectory vd = HostingEnvironment.VirtualPathProvider.GetDirectory(oldFileDir) as VersioningDirectory;
vd.BypassAccessCheck = true;
 //Shouldent this work?
vd.CopyTo(newVirtualPath);

                      

 

 

I have googled this but nothing works, can someone provide a simple example about copyng files.

 

#52204
Jul 12, 2011 8:12
Vote:
 

Seems very unnecessarily complicated. What must i do to make it work. Would really appreciate an answer, my employer really wants the old files to the new versioned folder.

#52295
Jul 15, 2011 8:20
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.