http://hanhead.tistory.com/entry/get-new-non-repeated-file-name-on-a-specific-folder

Private Function getNewFileName(strSavePath, strFileName)
 Dim fso
 Dim strStartName, strEndName
 Dim i
 Set fso = server.CreateObject("scripting.filesystemobject")
 If fso.FileExists(strSavePath & strFileName) = "True" Then
  If InStrRev(strFileName, ".") <> 0 Then 
   strStartName = Left(strFileName, InStrRev(strFileName, ".") - 1) 
   strEndName = Mid(strFileName, InStrRev(strFileName, ".")) 
  Else 
   strStartName = strFileName
   strEndName = "" 
  End If

  i = 2
  Do While (1)
   strFileName = strStartName & "(" & i & ")" & strEndName
   If fso.FileExists(strSavePath & strFileName) = "False" Then Exit Do 
   i = i + 1
  Loop
 End If
 Set fso = Nothing
 getNewFileName = strFileName
End Function

'asp' 카테고리의 다른 글

view source &asp coloring  (0) 2010.08.24
alert function in asp  (0) 2010.08.24
dbhelper class  (0) 2010.08.24
FSO example  (0) 2010.08.24
read/write configuration class (xml version)  (0) 2010.08.24

+ Recent posts