Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
1) Create a form with one button and a text line (button + textbox)
2) You will then enter the location of the text file in the text line
3) After clicking on the button, the program should load the text and at the same time create a second empty text (it doesn't matter where)
4) Then he had to go through the individual lines and the moment he finds a line with 3 stars, he looks at the previous line, reads the number of the map sheet from it (here 0404-D-07) and writes it in the new textbook.
5) After passing all lines, close both texts
6) The result should therefore be a text with the following lines:
0404-D-07
0404-D-10

Sorry for my english

What I have tried:

But I have only first two steps:
C#
public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Btn_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("C:\\Users\\Name.txt");

            System.Diagnostics.Process.Start("notepad.exe");
          
            }

            }
Posted
Updated 15-Sep-20 20:21pm
v2

We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

And I'll give you a clue: Your homework question tells you what to do, and does not even imply you should be using an external editor like Notepad or otherwise. Look at what the File and Stream classes can do for you instead.
 
Share this answer
 
Comments
dejf111 16-Sep-20 2:18am    
sorry for my post, but I can ask if at least the beginning is right?
My next step is:
C#
protected void FillForm(object sender, EventArgs e)
       {

           using (var streamReader = File.OpenText(@"C:\\Users\\Name.txt"))
           {
               string inputString = null;
               int lineNumber;
               do
               {
                   inputString = streamReader.ReadLine();
                   lineNumber++;


                   if (inputString.Contains("***"))
                   {
                       inputString = streamReader.ReadLine();

                       break;
                   }
               } while (inputString != null);
           }
       }
 
Share this answer
 
Comments
Richard MacCutchan 16-Sep-20 3:49am    
You are supposed to read the name of the file from a text block on the form. (2)
You should then load all the text from the file - see stream.ReadAllLines. (3)
When you find a line containing 3 stars you need to examine the previous line etc. (4)

Take one point at a time, write its code and test it. Do not move to the next until that part of the code works.
dejf111 16-Sep-20 4:06am    
now I test find:
class Program
{
static void Main(string[] args)
{
string[] lines = System.IO.File.ReadAllLines("C:\\Users\\mrazekd\\Downloads\\PrubehPripravyPat.txt");
string regMatch = @"\*";
foreach (string line in lines)
{
if (Regex.IsMatch (line, regMatch))
{
Console.WriteLine("found\n");
}
else
{
Console.WriteLine("not found\n");
}
}
}
}
it works but i don't know how it connect

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900