|
-
Mar 22nd, 2004, 08:32 AM
#1
Thread Starter
Fanatic Member
grab a file and put it in anoter
Greetings,
In my program, I extract a text file; and then after extraction, I rename the .txt file as a .~xt file, so that it will not be imported again.
So, what would be a way to take the backupfile (i.e. the ".~xt" file and put it in a different folder. Say I want the ".~xt" file to go in a folder called "C:\backupFiles" ?
Right now I have this code below, which simply renames the file, but keeps the file in its present directory.
bakfile = Mid(pathfile(i), 1, (Len(pathfile(i)) - 4)) & "bak" & nNow & ".~xt" 'formerly "~sv", changed to "~xt" by jrm 3/22/04
My goal is to send it to a backup directory. What do I need to do?
One other note, I do not want to keep a copy of the backup in the present directory; I just want to have it in "C:\backupFiles".
Thank you,
Jim
-
Mar 22nd, 2004, 08:36 AM
#2
To keep your current code, FileCopy statement and Kill statement.
-
Mar 22nd, 2004, 09:20 AM
#3
Thread Starter
Fanatic Member
Originally posted by leinad31
To keep your current code, FileCopy statement and Kill statement.
Sounds like a good plan, and I'm trying to implement it; but for the FileCopy line, below, I keep getting the error:
"Compile Error: Expected function or variable."
Any ideas? The code is below.
Thank you,
Jim
bakfile = Mid(pathfile(i), 1, (Len(pathfile(i)) - 4)) & "bak" & nNow & ".~xt" 'formerly "~sv", changed to "~xt" by jrm 3/22/04
Name pathfile(i) As bakfile 'change the name of pathfile(i) to bakfile
backupDirectory = "C:/AdcoleTextFileBackups"
pf = pathfile(i)
bakfile = FileCopy(pf, backupDirectory)
Kill pathfile(i)
-
Mar 22nd, 2004, 09:26 AM
#4
FileCopy doesnt return anything
VB Code:
FileCopy pf, backupDirectory
-
Mar 22nd, 2004, 11:37 AM
#5
Thread Starter
Fanatic Member
OK, we're on track with FileCopy.
One thing I need my code to do though is to create the destination folder before the FileCopy command is used.
What is the vb code for creating a folder? Say I want to create a folder called "C:\backupFiles".
How would I code that? The pseudocode being
create the folder called "C:\backupFiles"
Thank you,
Jim
-
Mar 22nd, 2004, 11:49 AM
#6
Frenzied Member
You can also use FSO to MoveFile or CopyFile as well.
-
Mar 22nd, 2004, 11:53 AM
#7
-
Mar 22nd, 2004, 12:09 PM
#8
Thread Starter
Fanatic Member
Originally posted by BrianS
You can also use FSO to MoveFile or CopyFile as well.
What's FSO?
-
Mar 22nd, 2004, 12:17 PM
#9
Thread Starter
Fanatic Member
Originally posted by leinad31
MkDir
OK, then how do I first say "if directory does not presently exist"?
If "C:\backupFiles" does not exist then
MkDir "C:\backupFiles"
End If
-
Mar 22nd, 2004, 01:11 PM
#10
Hyperactive Member
You can use Dir if I remember correcly...
VB Code:
If Dir(FileName) = "" or filename = "" then
msgbox "Directory not found!", "Error!" , vbexlamection
mkdir "c:\Backup"
end if
Something like that...
-
Mar 22nd, 2004, 02:03 PM
#11
Frenzied Member
If you have MSDN, look at the MoveFile and/or CopyFile commands for FSO (File System Object). I believe that either command will create the destination path if it doesnt exist, but I can't be 100% on that.
Originally posted by JimMuglia
What's FSO?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|