Solved

File association with my application.

Posted on 2011-02-16
3
830 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 14

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …

744 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

14 Experts available now in Live!

Get 1:1 Help Now