como renombrar un directorio

HMG en Español

Moderator: Rathinagiri

Post Reply
arroya2
Posts: 172
Joined: Thu Aug 06, 2009 7:16 am

como renombrar un directorio

Post 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
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: como renombrar un directorio

Post 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.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
arroya2
Posts: 172
Joined: Thu Aug 06, 2009 7:16 am

Re: como renombrar un directorio

Post by arroya2 »

Muchas gracias Pablo Cesar

Saludos
Rafael Pérez
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: como renombrar un directorio

Post by esgici »

Viva INTERNATIONAL HMG :D
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Como renombrar un directorio

Post 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.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: como renombrar un directorio

Post 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)
Attachments
Remove_Folder.zip
(2.95 KiB) Downloaded 165 times
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: como renombrar un directorio

Post 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
Viva INTERNATIONAL HMG :D
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: como renombrar un directorio

Post 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
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: como renombrar un directorio

Post 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
Viva INTERNATIONAL HMG :D
Post Reply