Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

File association with my application.

Posted on 2011-02-16
3
Medium Priority
?
879 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

Configuring Remote Assistance for use with SCCM
An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

650 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