Results 1 to 4 of 4

Thread: FileSystemObjetc

  1. #1
    Guest

    Angry

    Hi everyone

    Can i using file system object to rename my file since i can get file ?


    Also,
    Can anyone know how to using ASP to rotate image to maybe 90,180, 270 degree? Do anyone have the ASP component or where can I find it?



    Need response ASAP

    Thx in advance

    Mac

  2. #2
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722
    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

  3. #3
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722
    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

  4. #4
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722
    ****, 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
  •  



Click Here to Expand Forum to Full Width