Chaos Project

Game Development => Sea of Code => Topic started by: G_G on November 01, 2009, 01:04:36 pm

Title: Opening File?
Post by: G_G on November 01, 2009, 01:04:36 pm
Okay well I couldnt really think of a title.

What I want is when you go to open a file it, opens this c# program that reads that file.
For example, you open a txt file it opens up notepad then notepad reads that txt document.

How do I do that in C#?
Title: Re: Opening File?
Post by: Blizzard on November 01, 2009, 01:06:40 pm
I'm not sure how this is done manually (bullshit, it's done via registry), but it's called file extension association. Try googling it.
Title: Re: Opening File?
Post by: G_G on November 01, 2009, 01:53:26 pm
well I get that, what I'm trying to figure out is how to make my web browser open up an html file. I right clicked on an html file, clicked open with, then chose my browser. It didnt load up, I'm trying to make it so it does load that html file up.
Title: Re: Opening File?
Post by: Blizzard on November 01, 2009, 02:38:30 pm
Oh, that. I think it's done by passing on parameters when the application is run, but honestly I'm not sure. I think I tried the same thing with Blizz-ABS Config and failed at it myself.
Title: Re: Opening File?
Post by: G_G on November 01, 2009, 03:33:16 pm
Would the code in Program.cs have anything to do with it?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace GGP_Browser
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}
Title: Re: Opening File?
Post by: Blizzard on November 01, 2009, 03:42:28 pm
... Didn't Main take a string array as arguments?

static void Main(string[] args)


(Man, I hate when this happens. I'm all like "I don't know", then I remember that I did it actually earlier. >.<)

EDIT: BTW, you can remove Linq. You're not going to use it, trust me.