WinForm C# .NET #11 Viewing Directory Paths and Opening Files from Folders

Опубликовано: 13 Сентябрь 2026
на канале: Multiverso TI
1,316
15

In this lesson, we will learn how to navigate between the different directories of our application, identify the path of a folder, and open a file located within that folder. For our example, we will open an image and a Word document.

Code Used in this Lesson:
---------------------------------------------------
public partial class frmDirectorios : Form

{
public frmDirectorios()

{
InitializeComponent();

}

private void btnAbirDirectorio_Click(object sender, EventArgs e)

{
string ruta_imagen = "imagenes\\lista.png";

string ruta_word = "imagenes\\factura.docx";

string ruta = Environment.CurrentDirectory;

string ruta_padre = System.IO.Directory.GetParent(ruta).Parent.FullName;

string abrir_img = System.IO.Path.Combine(ruta_padre, ruta_word);

MessageBox.Show(path + "\n" + parent_path + "\n" + open_img);

System.Diagnostics.Process.Start(open_img);
}
}