Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
GeneralRe: Classes, events and best practices Pin
S. Senthil Kumar3-Jun-09 23:29
S. Senthil Kumar3-Jun-09 23:29 
Questionmysql connector Pin
benjamin yap3-Jun-09 4:59
benjamin yap3-Jun-09 4:59 
AnswerRe: mysql connector Pin
Ennis Ray Lynch, Jr.3-Jun-09 5:03
Ennis Ray Lynch, Jr.3-Jun-09 5:03 
GeneralRe: mysql connector Pin
benjamin yap3-Jun-09 5:13
benjamin yap3-Jun-09 5:13 
GeneralRe: mysql connector Pin
Ennis Ray Lynch, Jr.3-Jun-09 5:14
Ennis Ray Lynch, Jr.3-Jun-09 5:14 
GeneralRe: mysql connector Pin
benjamin yap3-Jun-09 5:21
benjamin yap3-Jun-09 5:21 
AnswerRe: mysql connector Pin
Christian Graus3-Jun-09 10:32
protectorChristian Graus3-Jun-09 10:32 
QuestionArguments! C# Pin
Baeltazor3-Jun-09 3:51
Baeltazor3-Jun-09 3:51 
Hey there Smile | :)

I have a richtext editor i've made in C#. It's just about finished. Everything works very well and i love it lol. But there's one thing I don't know how to do yet and that is inside the Program.cs file when I send the file contents of the file that was opened from within a folder in windows explorer to the richtextbox control on Form1 (SPage)... I don't know how to retreive the name of the file using the args... I don't know how to explain it I'm very confused atm... Here's my code, it works beautifully, I just need to be able to grab the filename and pass it to the Tabpage that it creates and set the Text property of the selected tab to the name of the file.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace J.T_Notes
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();

            if (args.Length >= 1)
            {
                SPage frm = new SPage(); // create a ref for form page.

                System.IO.StreamReader myFile = new System.IO.StreamReader(args[0]);
                
                string line = "";

                try
                {
                    line = myFile.ReadToEnd();

                    if (line.Contains(@"{\rtf1"))
                    {
                        frm.Tb.Rtf = line;
                        myFile.Close();
                    }
                    else
                    {
                        frm.Tb.Text = line;
                        myFile.Close();
                    }
                }
                catch
                {
                    // dunno y not working.
                    MessageBox.Show("damn... this ain't workin' so good!",
                        "J.T Notes 3.1");

                    Application.Restart();
                }
                Application.Run(frm);
            }
            else
                Application.Run(new SPage());
        }
    }
}



Does anybody know how to do this and/or have any suggestions or links to a tutorial/article as I am completely lost. Any help would be greatly appreciated! Thanks Smile | :)

regards,
j.t
AnswerRe: Arguments! C# Pin
Pete O'Hanlon3-Jun-09 3:59
mvePete O'Hanlon3-Jun-09 3:59 
GeneralRe: Arguments! C# Pin
Baeltazor3-Jun-09 4:04
Baeltazor3-Jun-09 4:04 
GeneralRe: Arguments! C# Pin
Nagy Vilmos3-Jun-09 4:12
professionalNagy Vilmos3-Jun-09 4:12 
GeneralRe: Arguments! C# Pin
Pete O'Hanlon3-Jun-09 4:28
mvePete O'Hanlon3-Jun-09 4:28 
GeneralRe: Arguments! C# Pin
Nagy Vilmos3-Jun-09 4:37
professionalNagy Vilmos3-Jun-09 4:37 
GeneralRe: Arguments! C# Pin
Luc Pattyn3-Jun-09 6:09
sitebuilderLuc Pattyn3-Jun-09 6:09 
GeneralRe: Arguments! C# Pin
0x3c03-Jun-09 4:18
0x3c03-Jun-09 4:18 
AnswerRe: Arguments! C# [modified] Pin
Luc Pattyn3-Jun-09 4:06
sitebuilderLuc Pattyn3-Jun-09 4:06 
GeneralRe: Arguments! C# Pin
Nagy Vilmos3-Jun-09 4:14
professionalNagy Vilmos3-Jun-09 4:14 
GeneralRe: Arguments! C# Pin
Luc Pattyn3-Jun-09 4:16
sitebuilderLuc Pattyn3-Jun-09 4:16 
GeneralRe: Arguments! C# Pin
Nagy Vilmos3-Jun-09 4:22
professionalNagy Vilmos3-Jun-09 4:22 
GeneralRe: Arguments! C# Pin
Baeltazor3-Jun-09 4:20
Baeltazor3-Jun-09 4:20 
GeneralRe: Arguments! C# Pin
Baeltazor3-Jun-09 4:28
Baeltazor3-Jun-09 4:28 
Questionthis.Refresh Pin
gwithey3-Jun-09 3:50
gwithey3-Jun-09 3:50 
AnswerRe: this.Refresh Pin
NickPace3-Jun-09 4:00
NickPace3-Jun-09 4:00 
GeneralRe: this.Refresh Pin
gwithey3-Jun-09 4:15
gwithey3-Jun-09 4:15 
GeneralRe: this.Refresh Pin
S. Senthil Kumar3-Jun-09 5:08
S. Senthil Kumar3-Jun-09 5:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.