Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

In my app I am using ASTreeView control and ASContextMenu.
In the context Menu I have the menu Items ADD,EDIT,DELELTE.

I am adding a folder it is successfully added to treeview and saved into database table.

Now my requirent is when successfully saved into database I have to create that folder with the name in my local machine "D:\ROOT".

For example if I add a folder named "HONEY" by Treeview Context menu, it will have added successfully in the database and I get return value "1" for successful insertion, now based on return val =1, I have to create the HONEY folder into D:ROOT(i.e D:\ROOT\HONEY\)

How can I solve this one,
If you know help me,

Thanks & Regards,
Honey

The OP added:


i solved that one by following
string MainRootFolder =@"D:\ROOT";

string newPath = System.IO.Path.Combine(MainRootFolder, 
obj.FName);

(In obj.Fname i am getting created folder name, ex:Honey)
System.IO.Directory.CreateDirectory(newPath);


but this is not my full requirement,
if i add sub Folder named BEE to HONEY Folder, according to the above code the new folder is adding in the D:\ROOT\BEE but i want like this D:\ROOT\HONEY\BEE
How i can solve this
If u know help me..
Posted
Updated 6-Feb-11 22:45pm
v3
Comments
Dalek Dave 7-Feb-11 4:45am    
Edited for Grammar, Readability and Code Block.

1 solution

Use the Directory.CreateDirectory(string)[^] method - you build the path from "D:\ROOT" and the name you saved to the database.


"if i add sub Folder named BEE to HONEY Folder, according to the above code the new folder is adding in the D:\ROOT\BEE but i want like this D:\ROOT\HONEY\BEE
How i can solve this"


Simple: just call System.IO.Path.Combine each time you need to add the folder:
MIDL
string MainRootFolder =@"D:\ROOT";
string newPath = System.IO.Path.Combine(MainRootFolder, obj.FName);
newPath = System.IO.Path.Combine(newPath, "BEE");
 
Share this answer
 
v2
Comments
honey4bee 7-Feb-11 3:47am    
again see my question and ans
OriginalGriff 7-Feb-11 3:53am    
Answer updated
honey4bee 7-Feb-11 4:19am    
how i can add that? it will goes to first ROOT, later Honey later Bee,,
if i have more how it is possible to go those parentes folders,
help me.
OriginalGriff 7-Feb-11 4:28am    
Without knowing a lot more about your code than I want to, perhaps if you used a loop, adding each folder name on as you go... (Hint, hint)
davfeu 7-Feb-11 4:22am    
string MainRootFolder =@"D:\ROOT";
string newPath = System.IO.Path.Combine(MainRootFolder, obj.FName, "BEE")

Wouldn't this be enough?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900