I have published a WPF Application and added a File Association.
When I click on my custom file *.bms
I actually want to read the file and work with it. How can I do this? So far, if I click on a *.bms
file it just opens the Application. Nothing else.
I have already tried adding:
<Application x:Class="WpfApplication1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml"
Startup="Application_Startup"> <!--this line added-->
<Application.Resources>
</Application.Resources>
private void Application_Startup(object sender, StartupEventArgs e)
{
if(e.Args.Length == 1) //make sure an argument is passed
{
FileInfo file = new FileInfo(e.Args[0]);
if(file.Exists) //make sure it's actually a file
{
//Do whatever
}
}
}
I got this solution from an answer by neeKo in This Question
But this didn't work for me neither.