|
-
Jun 25th, 2000, 06:18 PM
#1
-
Jun 25th, 2000, 06:34 PM
#2
Fanatic Member
OK.
To rename a file, I would do this:
1.) Read the whole file
2.) Write it to a new file
3.) Delete old file
about the rotating picture, if you can't find a component to do it, write one.
r0ach™
Don't forget to rate the post
-
Jun 25th, 2000, 06:50 PM
#3
Fanatic Member
Let me be clearer about the rename:
Code:
<%
Sub Rename(path, oldfile, newfile)
set fso = Server.CreateObject("Scripting.FileSystemObject")
'first check if path and oldfile is valid. I skipped it.
'assumed it's valid
'also check if newfile exist. we don't want to overwrite existing files
oPath = path & oldfile
nPath = path & newfile
'copy old file to new file
fso.CopyFile oPath, nPath, False
'delete old file
fso.DeleteFile oPath, True
Set fso = nothing
' you could leave out the path parameter,
' but then you must include it into each filename
End Sub
'Usage:
Rename("C:\My Documents\", "Test1.txt", "Test2.txt")
%>
Should work. Haven't tested it.
[Edited by r0ach on 06-26-2000 at 07:53 AM]
r0ach™
Don't forget to rate the post
-
Jun 25th, 2000, 07:00 PM
#4
Fanatic Member
****, sorry. Made a mistake.
CopyFile method won't take new filename for destination. (I think)
Replace the whole "fso.copyfile" line in previous post with:
Code:
'open file
Set oF = fso.GetFile oPath
'create new file
Set nF = fso.CreateFile nPath, False 'don't want to overwrite existing file
'copy old file to new file
nF.Write oF.ReadAll
'close files
oF.Close
nF.Close
r0ach™
Don't forget to rate the post
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
|