المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Arguments! C#



C# Programming
06-03-2009, 06:12 PM
Hey there http://www.barakasoft.com/script/Forums/Images/smiley_smile.gif

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
{
///
/// The main entry point for the application.
///
[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 http://www.barakasoft.com/script/Forums/Images/smiley_smile.gif

regards,
j.t