Try our conversational search powered by Generative AI!

Copy files between VirtualPathVersioningProviders


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.

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?




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


Jul 12, 2011 8:12

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.

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.