samsmithnz
Well-known member
Im trying to do a fairly simple move of a file from one folder to another. But Im having a little bit of trouble understanding the best way of handling it.
Currently I have:
The thing is I have a filename variable (holding "C:\projects\files\file.txt"), and Id like to move it to another folder ("C:\projects"), but if the file already exists, I need to delete/overwrite it. The problem is I need to take the filename from the strSourceFilePath, and append it to the strTargetPath variable.
Im sure there used to be an easy way to drop the path and extract the file name in the old FileSystemObject... How do I do that in .NET (without using the split function, there must be a cleaner way)
thanks
Sam
Currently I have:
Code:
Dim objFile As System.IO.File
Move the file to a new location
objFile.Move(strSourceFilePath, strTargetPath)
The thing is I have a filename variable (holding "C:\projects\files\file.txt"), and Id like to move it to another folder ("C:\projects"), but if the file already exists, I need to delete/overwrite it. The problem is I need to take the filename from the strSourceFilePath, and append it to the strTargetPath variable.
Im sure there used to be an easy way to drop the path and extract the file name in the old FileSystemObject... How do I do that in .NET (without using the split function, there must be a cleaner way)
thanks
Sam