Solved

File association with my application.

Posted on 2011-02-16
3
837 Views
Last Modified: 2012-05-11
I am trying to open an xml file with my custom winforms application through file associations.
I have the file evoke the application fine, but I need to know what events during application load I would need to override to consume the file and open it in my app.
I have a loadfile method that I use to traditionally open the files with IO objects in .NET.
But this never gets fired when the target "file" get's clicked and the app loads.

Any help would be great,
Mel
0
Comment
Question by:rotovibe
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
anarki_jimbel earned 500 total points
ID: 34913378
I believe what you need is to create your application to consume command line parameters.

I believe the system starts a new process and passes a file path as an argument

Your application needs to consume these arguments (e.g., file path)

Basicly, you need to modify the Programm cs class and Form1 constructor to consume file.

I didn't test this but worth to try :)

See modified Programm.cs file:
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace TwoForms
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1(args[0]));
        }
    }
}

Open in new window

0
 
LVL 29

Expert Comment

by:anarki_jimbel
ID: 34913383
BTW, you may need error handling if file path is wrong or is missing...
0
 
LVL 15

Expert Comment

by:DonConsolio
ID: 34913404
Try setting a file association from the desiread extension to your application



code example:
http://www.codeproject.com/KB/dotnet/System_File_Association.aspx
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error on link 14 37
SQL Exceptions 3 37
Javascript and Jquery not firing 9 39
Is my window10 Safe? after a malware removed by AV? 5 24
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now