|
-
August 26th, 2010, 03:45 AM
#1
send filename by the Right-Click send to context menu
Hey everybody!
I'm new here and in C#
I start to study it by myself and I'm trying to create a right-click context menu command for sending
the filename and path to my program.
So far I got simple program with textbox
my goal is when I'm clicking on the right click context menu and selecting SendTo-> MyApp
it will open MyApp and put the filename and his path to the textbox.
Thanx!
-
August 26th, 2010, 04:45 AM
#2
Re: send filename by the Right-Click send to context menu
You'll have to creat a shortcut for your program first in the "SendTo" folder. For example, if you're running XP, you'd need to follow these steps :
Click [Start] [All Programs] [Windows Explorer].
Navigate to the drive where Windows XP is installed.
Expand the Documents and Settings folder.
Expand the folder of the User whose Send To menu will be modified.
Expand the Send To folder.
(If the Send To folder isn't visible, click [Tools] [Folder Options] [View] tab and check [Show Hidden Files and Folders])
Right click any item you want to add, drag and drop it on the Send To folder and click [Create Shortcuts Here].
After this is done, use a program such as PathCopy ( which is free ) to copy the path of the selected file to the clipboard.
When your program launches, paste this contents in to your textbox.
-
August 27th, 2010, 10:52 AM
#3
Re: send filename by the Right-Click send to context menu
As HanneSThEGreaT said, you have to put a shortcut of your program in the SendTo folder (or alternatively, create a registry key in the SendTo folder).
After you do that, the user can open files with your program using the file's context menu. Your program will open, and the file's path will be stored in args[0], where [String[] args] is the parameter the Main gets.
Code:
private static void Main(String[] args)
{
if(args.Length == 0)
Console.WriteLine("MyApp was opened regulary...");
else
Console.WriteLine("A file was opened using MyApp. The file's path is: " + args[0]);
}
(If your current Main doesn't have a String[] args parameter, simply add it there)
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|