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);
}
}