file and folder copy

BlitzMax Forums/BlitzMax Beginners Area/file and folder copy

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I have not had much experience in file handling, so I am having some problems getting a specific program made.

I need to be able to copy files and folders from one location to another, but I need it to copy and delete the source files one file at a time.

I have the following code to go though folders and files, but I am uncertain as to how I can use this to do the above.

enumFiles("E:\applications")

Function enumFiles:Int(dir:String)
	
	Local folder:Int=ReadDir(dir)
	Local file:String
	Local fullpath:String

	Repeat
		file=NextFile(folder)
		If (file) And (file <> ".") And (file <> "..")
			fullPath = RealPath(dir+"/"+file)
			If FileType(fullPath)=FILETYPE_DIR
				Print "Folder: "+file
				enumFiles(fullPath)
			Else
				Print "File: "+file
			End If
		End If
	Until (file=Null)

	CloseDir folder
End Function


I cannot have it simply copy an entire directory at once, I need it to copy each file one at a time, and have it create the folders at the destination location one at a time as needed.