?
Solved

File association with my application.

Posted on 2011-02-16
3
Medium Priority
?
873 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 30

Accepted Solution

by:
anarki_jimbel earned 2000 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 30

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

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

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

This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
Windows 10 Creator Update has just been released and I have it working very well on my laptop. Read below for issues, fixes and ideas.
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…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

762 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