How to rename a file?

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

How to rename a file?

#1 Post by Eugene Lutsenko »

How to rename a file? For some reason it does not work. Surprised myself

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: How to rename a file?

#2 Post by rdonnay »

Show your code.
The eXpress train is coming - and it has more cars.

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: How to rename a file?

#3 Post by Eugene Lutsenko »

Code: Select all

        CLoseAll()             // Закрытие всех баз данных с ожиданием завершения операций
        DIRCHANGE(M_PathAppl)                                   // Перейти в папку текущего приложения
        IF FILE('Rasp.dbf')
           ERASE('Rasp.dbf')
        ENDIF
        mNameRsp = 'Rasp_'+LOWER(Ar_Model[mNumModel])+'.dbf'
*       RENAME FILE (mNameRsp) TO ('Rasp.dbf')
        COPY FILE (mNameRsp) TO ('Rasp.dbf')
COPY works but not the RENAME

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: How to rename a file?

#4 Post by rdonnay »

I use Frename() function.

It requires a full path name for both arguments.
The eXpress train is coming - and it has more cars.

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: How to rename a file?

#5 Post by Eugene Lutsenko »

Thank You, Roger! So it seems to work:

Code: Select all

        CLoseAll()             // Закрытие всех баз данных с ожиданием завершения операций
        DIRCHANGE(M_PathAppl)                                   // Перейти в папку текущего приложения
        mNameRspOld = M_PathAppl+'Rasp_'+LOWER(Ar_Model[mNumModel])+'.dbf'
        mNameRspNew = M_PathAppl+'Rasp.dbf'
        IF FILE(mNameRspNew)
           ERASE(mNameRspNew)
        ENDIF
        FRENAME(mNameRspOld,mNameRspNew)
[/size]

Victorio
Posts: 621
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: How to rename a file?

#6 Post by Victorio »

I am using this , with 10 attempts ,if it fails for the first time :

Code: Select all

	deletefile(cestatlac+"Supis_C_Parciel.pdf")
	FRename((cestatlac+"RauknReport.pdf"),(cestatlac+"Supis_C_Parciel.pdf"))
	pokus:=1
	do while file((cestatlac+"Supis_C_Parciel.pdf"))!=.T. .and. pokus<10
		sleep(300)
		FRename((cestatlac+"RauknReport.pdf"),(cestatlac+"Supis_C_Parciel.pdf"))
		pokus++
	enddo

Post Reply