Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Error 1015: Filerename failed

Keywords:  1015 filerename

Question:

Exactly what conditions cause the error 1015: FileRename?

Answer:

The following script checks the existence of source and target files.

You'll get the "1015 File Rename Failed" error if the source file does not exist, or if the target file already exists. This code checks that the source file exists, and that the target file is deleted if it exists, then renames the file.

src = "C:\temp\source.txt"
trg = "C:\temp\target.txt"
fesource=FileExist(src)
If fesource==1 ;Make sure source file exists
	Message("YEP",StrCat(src," exists"))
	fetarget=FileExist(trg)
	If fetarget==1 ;Delete target if it exists
		Message("YEP",StrCat(trg," exists")) 
		FileAttrSet(trg,"rash") ;Remove read-only attribute on target, so it can be deleted
		Errormode(@Off)
		ret = FileDelete(trg) ;Delete target file 
		Errormode(@on)
		If ret==0
			Message("Opps File was","NOT DELETED")
			exit
		Else
			Message("File was","DELETED")
			fn=FileRename(src,trg) ;Rename file
			message("Finished","File was renamed from source.txt to target.txt")
		Endif
	Endif
Endif

Article ID:   W12933
Filename:   1015 FileRename Failed.txt