Is there any way of opening a FOLDER for append.
Something like:
I want to move files from one folder to another without deleting any files in the target folder.Code:Open "Pathname/foldername" for Append
Printable View
Is there any way of opening a FOLDER for append.
Something like:
I want to move files from one folder to another without deleting any files in the target folder.Code:Open "Pathname/foldername" for Append
[copy]
'copy the contents of a floppy to a folder on a different drive
'copies files and folders seperately as they use different vehicles
'
Public Sub CopyA()
Dim FSO As Object
On Error GoTo NOFSO
Set FSO = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
FSO.CopyFile "A:\*", "C:\My Documents\", True
FSO.CopyFolder "A:\*", "C:\My Documents\", True
Set FSO = Nothing
Exit Sub
NOFSO:
MsgBox "FSO CreateObject Failed"
End Sub
[/code]
Is there any way to delete the origional files after the files have been copied. Like a MoveFile instead of CopyFile????
I don't think there is a way to move files using VB Code. You'd have to use the FileCopy and Kill statements. And if the files are the same name, I think they will be overwritten automatically.
Thanks for the help guys,
How would I go about using KILL? If I put it straight after the fileCopy, will that work?
Thanks again
JK
Are you saying you want to copy the file and then delete the file you copied since it doesn't move itself?
Copy the file first:
And then delete the file:Code:FileCopy "C:\Myfile.txt", C:\MyProgram\Myfile.txt"
Code:Kill "C:\Myfile.txt"
Yes that's it. The only problem that I have is that I don't know the name of the file. It's all based on the file extension. I want to copy all files in the folder with a file extension of .htm and leave all other files with different file extensions in the folder. Any ideas?
All the files are copied to the folder ok, but they won't delete from the original folder. Any SuggestionsCode:Private Sub Timer1_Timer()
Call CopyA
End Sub
Public Sub CopyA()
Dim FSO As Object
On Error GoTo NOFSO
Set FSO = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
FSO.CopyFile "C:\Documentation\*.htm", "C:\Test\", True
FSO.Kill "C:\Documentation\*.htm"
Set FSO = Nothing
Exit Sub
NOFSO:
MsgBox "FSO CreateObject Failed"
End Sub
[Edited by kanejone on 09-12-2000 at 05:11 AM]
Another question if possible. The folder that I'm putting the files into is actually going to be generated just before I do the FileCopy. This is how the folder name is going to be generated.
So what I need to do is something like this:Code:Private Function MakeFolder(NewDir As String)
Dim dirname As String
dirname = "C:\Documentation JK\"
NewDir = dirname & NewDir
MkDir NewDir
End Function
Private Sub Archive_Click()
today = Format(Now, "dd mmmm yyyy")
MakeFolder (today)
Call CopyA
End Sub
Is there any way to do this???Code:FSO.CopyFile "C:\Documentation\*.htm", "C:\Test\MAKEFOLDER(today)", True
Thanks for the time you've taken, I really to appreciate it