I have the following problem, which has a bit of a head ... :( I am formatting 3 string to form a path with Path.Combine (C # and WPF) in the first string has its origin in a TextBox (this is the problematic), the other two I get from an object.
My code is as follows:
string origen;
string destino;
List<Archivos> listaArchivosDescarga = DataTableToObjeto.ConvertirDataTableEnListaObjetos<Archivos>(archivos.BuscarPorVersion(1));
foreach(Archivos archivo in listaArchivosDescarga)
{
origen = Path.Combine(archivo.RutaServidor, archivo.NombreArchivoVirtual);
destino = Path.Combine(TbxRutaDestinoCliente.Text, archivo.Ruta, archivo.NombreArchivoFisico);
File.Copy(origen, destino, true);
}
The problem is that the second Combine that generates the destination of the file, passes completely from the TextBox content and at the time of formatting the route, only "sees" the last two variables of this line (file.Route and file. PhysicalFileName)
Within TextBox
I have for example: "C:\pruebas"
, in variable archivo.Ruta
, I have "\BIN\"
and in archivo.NombreArchivoFisico
: "cmdline.cmd"
, the result of Combine
is: "\BIN\cmdline.cmd"
.
Please, someone can give me a cable.
Thanks and best regards!