i am develop notepad project and deploy this project. after install this to select windows any text file .right click those file select openwith browse by installed file.
can't read this file .how to read this file directly with out using openfile dailog()
i am using textbox in my project.i am already used openfile dailod() in my notepad.
I want directly open windows text files in my notepad. please help me how to open this files
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace RTM____notepad
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
{
if (textBox1.Modified)
{
DialogResult ask;
ask = MessageBox.Show("Do you want to save the changes", "New Document", MessageBoxButtons.YesNo);
{
try
{
if (ask == DialogResult.No)
textBox1.Clear();
else if (ask == DialogResult.Yes)
saveFileDialog1.ShowDialog();
System.IO.StreamWriter file = new System.IO.StreamWriter(saveFileDialog1.FileName, true);
string text = textBox1.Text;
file.WriteLine(text);
file.Close();
textBox1.Clear();
}
catch
{
MessageBox.Show("you loss the data");
}
}
}
}
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
System.IO.StreamReader openFile = new System.IO.StreamReader(openFileDialog1.FileName);
textBox1.Text = openFile.ReadToEnd();
openFile.Close();
}
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
System.IO.StreamWriter saveFile = new System.IO.StreamWriter(openFileDialog1.FileName);
saveFile.WriteLine(textBox1.Text);
saveFile.Close();
}
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
{
saveFileDialog1.ShowDialog();
System.IO.StreamWriter saveFile = new System.IO.StreamWriter(saveFileDialog1.FileName);
saveFile.WriteLine(textBox1.Text);
saveFile.Close();
}
private void printToolStripMenuItem_Click(object sender, EventArgs e)
{
System.Drawing.Printing.PrintDocument prntDoc = new System.Drawing.Printing.PrintDocument();
}
private void printPreviewToolStripMenuItem_Click(object sender, EventArgs e)
{
System.Drawing.Printing.PrintDocument prntDoc = new System.Drawing.Printing.PrintDocument();
PrintPreviewDialog preview = new PrintPreviewDialog();
preview.Document = prntDoc;
if (preview.ShowDialog(this) == DialogResult.OK)
{
prntDoc.Print();
}
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
if (textBox1.Modified)
{
DialogResult ask;
ask = MessageBox.Show("Do you want to save the changes", "Exit", MessageBoxButtons.YesNo);
{
try
{
if (ask == DialogResult.No)
Application.Exit();
else if (ask == DialogResult.Yes)
saveFileDialog1.ShowDialog();
System.IO.StreamWriter file = new System.IO.StreamWriter(saveFileDialog1.FileName, true);
string text = textBox1.Text;
file.WriteLine(text);
file.Close();
Application.Exit();
}
catch
{
MessageBox.Show("you loss the data");
}
}
}
else
Application.Exit();
}
private void undoToolStripMenuItem_Click(object sender, EventArgs e)
{
textBox1.Undo();
}
private void redoToolStripMenuItem_Click(object sender, EventArgs e)
{
textBox1.Undo();
}
private void cutToolStripMenuItem_Click(object sender, EventArgs e)
{
textBox1.Cut();
}
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
{
textBox1.Copy();
}
private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
{
textBox1.Paste();
}
private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
{
textBox1.SelectAll();
}
private void fontToolStripMenuItem_Click(object sender, EventArgs e)
{
fontDialog1.ShowDialog();
textBox1.Font = fontDialog1.Font;
}
private void fontColourToolStripMenuItem_Click(object sender, EventArgs e)
{
colorDialog1.ShowDialog();
textBox1.ForeColor = colorDialog1.Color;
}
private void leftToolStripMenuItem_Click(object sender, EventArgs e)
{
textBox1.TextAlign = HorizontalAlignment.Left;
}
private void centerToolStripMenuItem_Click(object sender, EventArgs e)
{
textBox1.TextAlign = HorizontalAlignment.Center;
}
private void rightToolStripMenuItem_Click(object sender, EventArgs e)
{
textBox1.TextAlign = HorizontalAlignment.Right;
}
private void backgroundColourToolStripMenuItem_Click(object sender, EventArgs e)
{
colorDialog1.ShowDialog();
textBox1.BackColor = colorDialog1.Color;
}
}
}
the above program after initialization of frame. It is does not take input. so help this to take input if any windows text file double click to open this file into a my notepad. please help me
[edit]Code block added - OriginalGriff[/edit]