G
Guest
Hi all,
using C#, .NET 1.1, ASP.NET
I have created a recursive??? function. It looks a little like...
MyContext.Current.Folder.Parent.Parent.Parent.Parent.Name
As you can see, Parent is the recursive??? part.
Say I start from
/root/Folder1/Folder2/Folder3/Folder4/Folder5, I need to somehow record
where I am in the list, so that when I get to .Name, I see "Folder1".
Is there an easy way to see how many steps I have taken with Parent to reach
the folder name?
I had thought of using a property, but if I then call another similar
routine later, the property will remain.
I am thinking out loud here... this maybe a solution. Please glance your
eyes over it and let me know if it will work and if there are likely to be
any problems. What I do not know is if I reach the ".Folder", whether the
..Folder routine actually gets called before I run the .Parent, if you see
what I mean.
1. Set up a CurrentFolder property.
2. in .Folder, reset the CurrentFolder property to the actual folder where
we are at, i.e. "/root/Folder1/Folder2/Folder3/Folder4/Folder5"
3. Each time .Parent is called, change the CurrentFolder property to the new
Folder Path.
4. When Name is called, read off the CurrentFolder.
Will this actually run?
I may have a scope problem here as well...
MyContext is a class that has a "Folder" property, which is based on a
Folders class. The Folders class has "Parent", which is the recursive Folders
class.
(Code sample may help)
public class MyContext
{
public Folders Folder
{ get {return null;} } // ignore the return value, this will be filled
later.
}
public class Folders
{
private Folders thisParent;
public Folders()
{
thisParent = this;
}
public Folders Parent
{
get { return thisParent; }
}
public string Name
{
get { return "FolderName"; } // This will return something properly.
}
}
So, with the above, how do I keep track of the .Parent ?
Thanks
Regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available
using C#, .NET 1.1, ASP.NET
I have created a recursive??? function. It looks a little like...
MyContext.Current.Folder.Parent.Parent.Parent.Parent.Name
As you can see, Parent is the recursive??? part.
Say I start from
/root/Folder1/Folder2/Folder3/Folder4/Folder5, I need to somehow record
where I am in the list, so that when I get to .Name, I see "Folder1".
Is there an easy way to see how many steps I have taken with Parent to reach
the folder name?
I had thought of using a property, but if I then call another similar
routine later, the property will remain.
I am thinking out loud here... this maybe a solution. Please glance your
eyes over it and let me know if it will work and if there are likely to be
any problems. What I do not know is if I reach the ".Folder", whether the
..Folder routine actually gets called before I run the .Parent, if you see
what I mean.
1. Set up a CurrentFolder property.
2. in .Folder, reset the CurrentFolder property to the actual folder where
we are at, i.e. "/root/Folder1/Folder2/Folder3/Folder4/Folder5"
3. Each time .Parent is called, change the CurrentFolder property to the new
Folder Path.
4. When Name is called, read off the CurrentFolder.
Will this actually run?
I may have a scope problem here as well...
MyContext is a class that has a "Folder" property, which is based on a
Folders class. The Folders class has "Parent", which is the recursive Folders
class.
(Code sample may help)
public class MyContext
{
public Folders Folder
{ get {return null;} } // ignore the return value, this will be filled
later.
}
public class Folders
{
private Folders thisParent;
public Folders()
{
thisParent = this;
}
public Folders Parent
{
get { return thisParent; }
}
public string Name
{
get { return "FolderName"; } // This will return something properly.
}
}
So, with the above, how do I keep track of the .Parent ?
Thanks
Regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available