I'm trying to select a set of lines and process each line separately in a text document using c# language. How can i get separate lines to process? I tried these codes and got struck. Can anyone please help me with this?
EnvDTE.DTE dte = MyPackage.MyPackagePackage.GetGlobalService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
EnvDTE.TextSelection text = (dte.ActiveDocument.Selection as EnvDTE.TextSelection);
If you are reading from a text file this code will help you:
string fileToRead = "D:\\temp.txt"; // Temp.txt is the file to read
if (File.Exists(fileToRead))
{
StreamReader reader = new StreamReader(fileToRead);
do
{
textBox1.Text += reader.ReadLine() + "\r\n"; // Read each line and pass it to the TextBox1
} while (reader.Peek() != -1);
reader.Close(); // Close the file
}