Page 1 of 1

como renombrar un directorio

Posted: Mon Jul 13, 2015 4:34 pm
by arroya2
Hola amigos/as

¿Existe alguna función para renombrar un directorio desde un programa hecho con HMG?

Espero alguna respuesta.

Gracias
Rafael Pérez

Re: como renombrar un directorio

Posted: Mon Jul 13, 2015 5:22 pm
by Pablo César
Nenombrar o mover un directorio, dependerá de los derechos y tambien del So por si está siendo usado por otra aplicacion.

Creo que lo que se puede utilizar es el CREATEFOLDER, copiar todo el contenido y REMOVEFOLDER.

Re: como renombrar un directorio

Posted: Sat Jul 18, 2015 11:10 am
by arroya2
Muchas gracias Pablo Cesar

Saludos
Rafael Pérez

Re: como renombrar un directorio

Posted: Sat Jul 18, 2015 11:40 am
by esgici

Como renombrar un directorio

Posted: Sat Jul 18, 2015 1:58 pm
by Pablo César
El FRename, renombra archivos y directorios tambien como mostró Esgici (bien recordado).

Pero como dije anteriormente, todo dependerá si no hay nada abierto en ese directorio. Porque sinó, no tendrá suceso en renombrarlo.

Hice este ejemplo para demonstrarlo. Inclusive puedes tratar el resultado del valor retornado de la función FRename.

Code: Select all

#include <hmg.ch>
#include "fileio.ch"

Function Main()
Local nResult

RemoveAll()
hb_IdleSleep( 10 )
hb_MemoWrit(GetCurrentFolder()+"\x\test.txt","test1"+CRLF+"test2")
If MsgYesNo("Open Test.txt file now ?")
   SetCurrentFolder(GetCurrentFolder()+"\x")
   EXECUTE FILE "test.txt"
Endif
nResult := FRename( "x", "x1" )
IF nResult == F_ERROR
   MsgStop("File could not be renamed.","Error number: "+Str(nResult))
ELSE
   MsgInfo("Folder renamed successfully !")
ENDIF
// RemoveAll()
Return Nil

Function RemoveAll()
Delete File(GetCurrentFolder()+"\x\test.txt")
RemoveFolder("x")
Delete File(GetCurrentFolder()+"\x1\test.txt")
RemoveFolder("x1")
Return Nil
Sea en HMG como Harbour puro, es posible. Pero lo mejor es antecipar las posibles situaciones.

Re: como renombrar un directorio

Posted: Fri Dec 21, 2018 2:29 pm
by mustafa
Hello friends:
This sample is presented not as "Inventor of Fire" :oops:
but tired of not being able to find
Delete a folder and its sub-folders

If the folder is called [Document] in CMD it would be:
c: \> RD / s Document (Delete? Yes / No)

Finally I found:
http://www.hmgforum.com/viewtopic.php?f ... der#p42132
the sample created by the ill-fated friend Pablo César

and also:
http://www.hmgforum.com/viewtopic.php?f ... der#p14474
+ Added: CreateFolder ()
+ Added: RemoveFolder ()
by friend Rathinagiri

It has served as a base to create this sample that ami is serving me as useful
To delete folders, I hope I can serve you :idea:

Mustafa

PD: Remember that the Folders and sub-folders to delete them have to be if no file
inside (Empty)

Re: como renombrar un directorio

Posted: Fri Dec 21, 2018 2:53 pm
by esgici
Try MOVE command of DOS (console mode):

MOVE <cOldDirName> <cNewDirName>

( if required, search executing DOS commands within a HMG application ).

Happy HMG'ing :D

Re: como renombrar un directorio

Posted: Fri Dec 21, 2018 3:32 pm
by mustafa
Hola amigo esgici
As salamu Alaikum
Lo que yo queria era Borrar Carpetas y Sub-Carpetas
Con mi sample ya me está funcionando
Saludos
Mustafa
PD: Algún día volveré a mi querido Istambul , Inshallah
*-------------------------- Google ------------------------------------*

Hi friend esgici
Assalamu Alaikum
What I wanted was to Delete Folders and Sub-Folders
With my sample, it's already working
regards
Mustafa

PD: Someday I will return to my beloved Istambul, Inshallah

Re: como renombrar un directorio

Posted: Sat Dec 22, 2018 12:47 pm
by esgici
mustafa wrote:
Fri Dec 21, 2018 3:32 pm
Hi friend esgici
Assalamu Alaikum
What I wanted was to Delete Folders and Sub-Folders
With my sample, it's already working
Alaikum Assalam ve Rahmatullah my hermano

You are right; two ways are working; one is long, second is short ;(
PD: Someday I will return to my beloved Istambul, Inshallah
After Egypt or another place ?

I wish to see you, sadly Istanbul a very far way for me :(

Have a nice trip