you can do it like this:
1) go to your form class and add this constructor:
public Form1(string filename)
{
InitializeComponent();
//get all the text of text file
string[] readText = System.IO.File.ReadAllLines(filename);
//insert the string array in your richtextbox
foreach (string s in readText)
{
richTextBox1.Text += s + Environment.NewLine;
}
}
2) go to your Program class and change the code from your Main() method to this :
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (args[0] != null)
{
//args[0] exsists, so a file gets opened
//args[0] is the file path
Application.Run(new Form1(args[0]));
}
else
{
//args[0] doesn't exsist
Application.Run(new Form1());
}
}
make sure your Main method has the parameter 'string[] args'! if your method doesn't, just add it here
static void Main(string[] args)
3) build your project, go to your .exe file in the bin folder and test it by dropping a text file on top of the .exe (if i understand your question)