Reputation: 65
I want to add my Application so when I right click on a file , it shows the Send To > My App.
If its possible then , when I click on the SendTo button , how can I get the Selected file ...?? I didn't tried anything before or even found something that can help. Thanks :=)
Upvotes: 5
Views: 2944
Reputation: 2836
You can add a shortcut to your application to
%AppData%\Microsoft\Windows\SendTo
To navigate to that folder, you can also open a explorer window and type
shell:sendto
into the addressbar.
When you use the Send To
context menu, a new instance of your application will be started and you can get the path to the file which you sent to your application via the commandline arguments. For a console application this would be the args
parameter of the Main
method. Another way is Environment.GetCommandLineArgs();
.
Edit: Add sample console application
namespace TestApplication
{
public class Program
{
public void Main(string[] args)
{
String filePath = args[0];
Console.Write("The file you sent here: ");
Console.WriteLine(filePath);
Console.ReadLine();
}
}
}
This assumes that the app ist started with no other arguments. If there are other arguments, the filepath could be on another index in the args
array.
Sample output of this console app could be:
The file you sent here: C:\tmp\file.txt
Upvotes: 13