Opening File?

Started by G_G, November 01, 2009, 01:04:36 pm

Previous topic - Next topic

G_G

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#?

Blizzard

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.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

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.

Blizzard

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.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

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());
        }
    }
}

Blizzard

November 01, 2009, 03:42:28 pm #5 Last Edit: November 01, 2009, 03:45:05 pm by Blizzard
... 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.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.