asp classic - Using File System Object with case sensitive file names -


i have old vbscript function save file copy on server url. if file exists function deletes previous version , rewrites new file version. problem need insert case sensitive file names. instance, file names "test.html" , "test.html" should saved different copys , function replaces them. suggestion?

the function:

public function savetochache(url, savetofolder, filename)     dim chachefolder: chachefolder = savetofolder 'folder cache files   stored (include trailing slash)     dim filepath: filepath = server.mappath(chachefolder & filename)      dim objxmlhttp: set objxmlhttp = createobject("winhttp.winhttprequest.5.1")      objxmlhttp.open "get", url, false      objxmlhttp.send()      if objxmlhttp.status = 200           dim objadostream: set objadostream = createobject("adodb.stream")          objadostream.open          objadostream.type = 1 'adtypebinary          objadostream.write objxmlhttp.responsebody          objadostream.position = 0 'set stream position start          dim objfso: set objfso = createobject("scripting.filesystemobject")         if objfso.fileexists(filepath) objfso.deletefile filepath         set objfso = nothing         objadostream.savetofile filepath         objadostream.close         set objadostream = nothing         savetochache = objxmlhttp.getresponseheader("content-type")     else         savetochache = ""     end if     set objxmlhttp = nothing end function 

calling function:

savefile = savetochache("http://www.example.com", "/cache/", "test.html") 

thanks!

i use direct compare instead of objfso.fileexists.

for example:

dim objfso: set objfso = createobject("scripting.filesystemobject") filepath = "c:\test\test.txt"  'get path file strparentpath = objfso.getfile(filepath).parentfolder 'get each file in folder set objcheck = objfso.getfolder(strparentpath).files  each x in objcheck     if x = filepath objfso.deletefile(filepath) next  

basically, x equal filepath if case same.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -