1
Hello, everybody!
For study purposes, I created my own custom notepad, it can open files and get the text of a common Windows notepad through Openfiledialog and transfer to my program.
However I want that when the user opens the file from the windows interface, the text that file is transferred to my current one, but I don’t know how to do it without using Openfiledialog.
This method happens when the user clicks on "Open File". The abrirArquivo.FileName provides me the path and from that path I can transfer data to my program. I want to do the same thing when the user clicks on "Open" from Windows, but without using Openfiledialog.
private void MenuAbrirArquivo_Click(object sender, EventArgs e)
        {
            // Cria uma janela para abrir um arquivo
            var abrirArquivo = new OpenFileDialog();
            abrirArquivo.Title = "Selecione um arquivo";
            abrirArquivo.Filter = "txt file|*txt";
            abrirArquivo.RestoreDirectory = true;
            // Pega o resultado de qual botão ele clicou
            var resultado = abrirArquivo.ShowDialog();
            // User escolheu um arquivo
            if (resultado == DialogResult.OK)
            {
                // Cria um leitor para transferir os dados para o programa atual
                using(var leitor = new StreamReader(abrirArquivo.FileName))
                {
                    txtTexto.Text = leitor.ReadToEnd();
                }
                nomeArquivo = abrirArquivo.SafeFileName;
                path = abrirArquivo.FileName;
                SalvarModificacoes();
            }
        }
						

Thank you very much, Leandro! I spent 3 days looking for how to get this information and you helped me a lot! I thank you from my heart =D. But the way of the . txt is not in args[0], it is in args[1].
– Gabriel Bento
You are right, I was in doubt of that point when I answered, the args[0] gets the name of the exe if I am not mistaken. Updated answer!
– Leandro Requena