Click here to Skip to main content
15,905,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have added a new item 'ADD' in Context Menu of folder in Windows Explorer.

By right click a folder and select ADD in the context menu, all files in the folder have to be read. For this, I need to know the name of the folder just selected in the explorer.

How can I retrieve the name of the folder when I right click the context menu?
Posted
Updated 17-Jan-10 23:41pm
v2

If you use Path.GetFilename, it will actualy return the directory name from the full path passed into it.
 
Share this answer
 
The path I have retrieved doesn't have the name of the folder. If I selected a Folder named 'Debug' in the path C:\Files , it will retrieve only C:\Files. Thus Path.GetFileName(c:\Files) give me 'Files' as name of my folder. But I needed 'Debug' as the folder name or C:\Files\Debug as CurrentDirectory.
 
Share this answer
 
Perhaps what you want to do, is get the path to your application's exe, instead of the current directory ?

By the way, PLEASE edit your post, don't post fake answers, it just makes the forums hard to read.
 
Share this answer
 
Use the Split to the path ....
from...
Path.GetFilename().......

den u can the path of any folder u want


string temp = e.Name;
string[] temp_path = null;

temp_path = temp.Split(new Char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);

:-O :)
 
Share this answer
 
v2
When I right click a folder in Windows Explorer and select my context menu, I need to read the files in that folder.

For that I need the name of the selected folder.

How can I obtain it?
 
Share this answer
 
*sigh* you are a retard. I explained why you need to edit your post and not post answers, and you ignored me.

I see what you're doing now. The current folder IS the folder you're getting, the folder you want, is the one you selected, within the current folder. If it's not passed as an argument to the executable that is being run from the shell, then I doubt it's possible.
 
Share this answer
 

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