![]() |
| |||||||
| Registrarse | Preguntas Frecuentes | Lista de Foreros | Calendario | Buscar | Temas de Hoy | Marcar Foros Como Leídos |
![]() |
| | LinkBack | Herramientas | Desplegado |
|
#1
| |||
| |||
| Hola a todos Estoy copiando unos cuantos ficheros de C: a un Servidor. El problema es que a Windows XP se le corta la conexión unos instante y luego la recupera. Si al programa le pilla el Corte cuando esta copiando da error. Hay alguna manera de hacer que el Programa ReEstablezca la conexión, o al menos, que se espere para copiar hasta que Windows XP reestablezca la conexión. Un saludo y gracias por todo Darhas Este es el código que utilizo para copiar, está sacado de las MSDN de Microsoft: private bool CopiarFichero(string DirectorioOrigen, string FicheroOrigen, string DirectorioFinal, string FicheroFinal, bool SobreEscribir) { bool Correcto = false; bool CorrectoOrigen = false; bool CorrectoFINAL = false; string fileName = FicheroOrigen; string sourcePath = DirectorioOrigen; string targetPath = DirectorioFinal; // Use Path class to manipulate file and directory paths. string sourceFile = System.IO.Path.Combine(sourcePath, fileName); string destFile = System.IO.Path.Combine(targetPath, FicheroFinal); // To copy a folder's contents to a new location: // Create a new target folder, if necessary. if (!System.IO.Directory.Exists(targetPath)) { System.IO.Directory.CreateDirectory(targetPath); } if (System.IO.Directory.Exists(sourcePath)) { string[] files = System.IO.Directory.GetFiles(sourcePath); // Copy the files and overwrite destination files if they already exist. foreach (string s in files) { // Use static Path methods to extract only the file name from the path. if (SobreEscribir == true) { if (!System.IO.File.Exists(destFile)) { System.IO.File.Delete(destFile); System.IO.File.Copy(sourceFile, destFile); Correcto = true; } } else { if (!System.IO.File.Exists(destFile)) { System.IO.File.Copy(sourceFile, destFile, true); Correcto = true; } else { Correcto = false; } } } } else { Console.WriteLine("Source path does not exist!"); Correcto = false; } // Keep console window open in debug mode. //Console.WriteLine("Press any key to exit."); //Console.ReadKey(); return (Correcto); } |
| | ||||
| ||||
| |
|
#2
| |||
| |||
| Hola compañeros De verdad nadie sabe como hacerlo??? Estoy desesperado ![]() "Darhas" wrote: > Hola a todos > > Estoy copiando unos cuantos ficheros de C: a un Servidor. > > El problema es que a Windows XP se le corta la conexión unos instante y > luego la recupera. > > Si al programa le pilla el Corte cuando esta copiando da error. > > Hay alguna manera de hacer que el Programa ReEstablezca la conexión, o al > menos, que se espere para copiar hasta que Windows XP reestablezca la > conexión. > > Un saludo y gracias por todo > Darhas > > Este es el código que utilizo para copiar, está sacado de las MSDN de > Microsoft: > > private bool CopiarFichero(string DirectorioOrigen, string FicheroOrigen, > string DirectorioFinal, string FicheroFinal, bool SobreEscribir) > { > bool Correcto = false; > bool CorrectoOrigen = false; > bool CorrectoFINAL = false; > > string fileName = FicheroOrigen; > string sourcePath = DirectorioOrigen; > string targetPath = DirectorioFinal; > > // Use Path class to manipulate file and directory paths. > string sourceFile = System.IO.Path.Combine(sourcePath, fileName); > string destFile = System.IO.Path.Combine(targetPath, > FicheroFinal); > > > > // To copy a folder's contents to a new location: > // Create a new target folder, if necessary. > if (!System.IO.Directory.Exists(targetPath)) > { > System.IO.Directory.CreateDirectory(targetPath); > } > > > if (System.IO.Directory.Exists(sourcePath)) > { > string[] files = System.IO.Directory.GetFiles(sourcePath); > > // Copy the files and overwrite destination files if they > already exist. > foreach (string s in files) > { > // Use static Path methods to extract only the file name > from the path. > if (SobreEscribir == true) > { > if (!System.IO.File.Exists(destFile)) > { > System.IO.File.Delete(destFile); > System.IO.File.Copy(sourceFile, destFile); > Correcto = true; > } > } > else > { > if (!System.IO.File.Exists(destFile)) > { > System.IO.File.Copy(sourceFile, destFile, true); > Correcto = true; > } > else > { > Correcto = false; > } > } > } > } > else > { > Console.WriteLine("Source path does not exist!"); > Correcto = false; > } > > // Keep console window open in debug mode. > //Console.WriteLine("Press any key to exit."); > //Console.ReadKey(); > > return (Correcto); > } |
|
#3
| |||
| |||
| Hola RFOG, El problema principal es que es servidor no depende de mi ![]() Por eso pregunta, de como puedo forzar una reconexión, si se puede claro. De esta forma se solucionarÃ***an todo los problemas. O al menos lo apaliarÃ***a. Lo del TRY y CATH lo estoy haciendo, pero es muy limitado, ya que basicamente compruebo que exista un ruta, pero esto no fuerza una reeconexión como lo harÃ***a haciendo doble CLICK sobre el mapeo del Servidor. No obstante muchas gracias por la respuesta. Darhas |
| |
| |
| Herramientas | |
| Desplegado | |
| |
Temas Similares | ||||
| Tema | Autor | Foro | Respuestas | Último mensaje |
| Mensaje al copiar ficheros | Arturo Herrera | Newsgroup microsoft.public.es.windowsxp | 0 | 28-05-2009 12:22:04 |
| Copiar ficheros en red. | jabiermartines | Newsgroup es.comp.lenguajes.c++ | 0 | 09-10-2008 11:32:16 |
| Wordstar. Para viejales: ¿cómo ver los ficheros de Wordstar y como copiar o convertir el texto a ficheros de Word? | JM | Newsgroup microsoft.public.es.word | 12 | 23-09-2008 21:28:01 |
| No copiar ficheros ocultos | rvm | Newsgroup es.comp.os.linux.misc | 36 | 20-01-2008 16:58:10 |
| Impedir copiar ficheros de RED | Lince | Newsgroup es.comp.redes.misc | 68 | 06-05-2005 23:39:33 |