I'm using a TreeNode
subclasses in a NodeStore
and recursing through the filesystem to be presented in a NodeView
.
public void update(){
if(project.LocalCopyExists()){
Clear();
readDirectory(project.LocalPath, null);
}
}
void readDirectory (string parent, SourceFileHelper parentHelper)
{
foreach (string path in Directory.GetDirectories (parent)) {
//dirIter = AddEntity(parentIter, new SourceFileHelper(path, project));
var child = new SourceFileHelper(path,project);
AddEntity(parentHelper, child);
readDirectory(path, child);
}
foreach( string file in Directory.GetFiles( parent)){
AddEntity(parentHelper,new SourceFileHelper(file,project));
}
}
public void AddEntity(SourceFileHelper parent, SourceFileHelper helper){
if(helper.Hidden) return;
if(parent == null){
AddNode(helper);
}else{
parent.AddChild(helper);
}
}
To be honest, I've not been happy about having to do this at all, so if anybody knows of a reliable file browser I can plug in to my Mono project that would be easier.
Otherwise, I'm trying to see how, in a memory-efficient manner (i.e. without recreating the entire tree each time), to keep this structure up to date. Also, rebuilding would be bad because it would kill the user's current selection in the NodeView
.
Otherwise, I'm looking at FileSystemWatcher
.