Re: Tree Recursion for Copy Paste overwrite
Adam Tuliper <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.advanced |
|---|---|
| Message-ID | <[email protected]> |
Wouldnt the logic go something like this (you may be this far already)
1. take existing tree
2. build tree of destination
3. start folder by folder comparison, if folder exists, item by item.
4. if match is found and its first match/overwrite all=false then prompt
(continue building tree in background while waiting)
5. if user selects overwrite all, thats last time for prompt
6. continue to loop through each node on each side only on matching name.
extremely _roughly_n and Im sure Im missing something until Id sit down and
actually do it..
CompareFolder(node a, node b)
{
if a.name=b.name prompt to overwrite, delete destination if so otherwise
change node b name or cancel the operation (copy, copy replace, cancel)
--will only get called for items that need comparison - ie exist in b
(destination)
if a.name=b.name CompareFolderContents(a,b)
}
CompareFolderContents(a,b)
{
list items in both folders
foreach item in source, check for destination - if exists prompt for
overwrite if flag not set to ignore.
if item is a folder and exists in b, CompareFolder(source folder, dest
folder)
}
On Fri, Feb 13, 2009 at 7:31 AM, Peter Osucha <[email protected]>wrote:
> Sorry, Mike, I wasn't very clear with my issue.
>
> In Windows Explorer, suppose I have a tree structure with the folders
> 'MyFolderA' and 'F1' at the same level. Suppose that 'MyFolderA' also
> has a folder underneath it called 'F1'. If I copy the folder 'F1' that
> is at the level 'MyFolderA' into 'MyFolderA', I get a message that the
> folder 'F1' already exists asking me if I'd like to overwrite any files
> or folders underneath the existing 'MyFolderA-->F1' with the ones I am
> pasting.
>
> What I can't figure out is how to do this 'overwriting' from a 'travel
> through the treenode' standpoint...
>
> Peter
>
> -----Original Message-----
> From: Discussion of advanced .NET topics.
> [mailto:[email protected]] On Behalf Of Mike Andrews
> Sent: Thursday, February 12, 2009 4:29 PM
> To: [email protected]
> Subject: Re: [ADVANCED-DOTNET] Tree Recursion for Copy Paste overwrite
>
> I'm not sure I understand the question.
> When you paste a new folder in explorer that you have copied from a
> previous
> location, it renames the top-level folder so that it is unique with a
> "Copy
> of XXXX" folder.
>
>
> On Thu, Feb 12, 2009 at 3:24 PM, Peter Osucha
> <[email protected]>wrote:
>
> > Hello,
> >
> > I am trying to implement a copy-n-paste mechanism for a tree structure
> > similar to what Windows Explorer does. The case I can't figure out
> how
> > to program is that in which I am copying a node (and its children)
> > underneath a node and wanting to make sure there are no duplicates
> > (again, the same way Windows Explorer 'forces' files to be overwritten
> > if they have duplicate names).
> >
> > For the life of me, I can't figure out how to do this and googling has
> > yet to turn up an answer.
> >
> > Help (please)?
> >
> > Peter
>
> ===================================
> View archives and manage your subscription(s) at
> http://peach.ease.lsoft.com/archives
>
===================================
View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives