como renombrar un directorio
Moderator: Rathinagiri
como renombrar un directorio
Hola amigos/as
¿Existe alguna función para renombrar un directorio desde un programa hecho con HMG?
Espero alguna respuesta.
Gracias
Rafael Pérez
¿Existe alguna función para renombrar un directorio desde un programa hecho con HMG?
Espero alguna respuesta.
Gracias
Rafael Pérez
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Re: como renombrar un directorio
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.
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
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Re: como renombrar un directorio
Muchas gracias Pablo Cesar
Saludos
Rafael Pérez
Saludos
Rafael Pérez
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: como renombrar un directorio
Viva INTERNATIONAL HMG
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Como renombrar un directorio
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.
Sea en HMG como Harbour puro, es posible. Pero lo mejor es antecipar las posibles situaciones.
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
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- mustafa
- Posts: 1160
- Joined: Fri Mar 20, 2009 11:38 am
- DBs Used: DBF
- Location: Alicante - Spain
- Contact:
Re: como renombrar un directorio
Hello friends:
This sample is presented not as "Inventor of Fire"
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
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
Mustafa
PD: Remember that the Folders and sub-folders to delete them have to be if no file
inside (Empty)
This sample is presented not as "Inventor of Fire"
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
by friend Rathinagiri+ Added: CreateFolder ()
+ Added: RemoveFolder ()
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
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 239 times
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: como renombrar un directorio
Try MOVE command of DOS (console mode):
MOVE <cOldDirName> <cNewDirName>
( if required, search executing DOS commands within a HMG application ).
Happy HMG'ing
MOVE <cOldDirName> <cNewDirName>
( if required, search executing DOS commands within a HMG application ).
Happy HMG'ing
Viva INTERNATIONAL HMG
- mustafa
- Posts: 1160
- Joined: Fri Mar 20, 2009 11:38 am
- DBs Used: DBF
- Location: Alicante - Spain
- Contact:
Re: como renombrar un directorio
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
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
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: como renombrar un directorio
Alaikum Assalam ve Rahmatullah my hermano
You are right; two ways are working; one is long, second is short ;(
After Egypt or another place ?PD: Someday I will return to my beloved Istambul, Inshallah
I wish to see you, sadly Istanbul a very far way for me
Have a nice trip
Viva INTERNATIONAL HMG