home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / asppw112 / copyfile.asp next >
Encoding:
Text File  |  1999-01-07  |  2.2 KB  |  75 lines

  1. <HTML><BODY>
  2. <%
  3.     ' Method: CopyFileEx(strOrginalDirectory, strNewDirectory, strCopyPattern)
  4.     '          CopyFile(strSrcPathName, strTrgtPathName)
  5.     '
  6.     ' Sample Operation:
  7.     ' Copy files in directory of DirOrg to DirNew.
  8.     '
  9.     ' This file is provided as part of  ASP Power Widgets Samples
  10.     '
  11.     ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
  12.     ' WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
  13.     ' INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
  14.     ' OF MERCHANTABILITY AND/OR FITNESS FOR A  PARTICULAR
  15.     ' PURPOSE.
  16.  
  17.     ' Copyright 1997-1998. All rights reserved.
  18.     ' Dalun Software Inc. ASP Power Widgets
  19.     ' http://www.dalun.com
  20.     ' http://members.tripod.com/ActiveServerPage/
  21.  
  22.     sDirOrg   = "DirOrg"
  23.     sDirNew   = "DirNew"
  24.     sDirOrg   = Server.MapPath("/") & "\" & sDirOrg 'sDirOrg = D:\inetpub\wwwroot\dirorg
  25.     sDirNew   = Server.MapPath("/") & "\" & sDirNew
  26.  
  27.     response.write "Files in """ &  sDirOrg & """ will be copied to """ & sDirNew  & """.<br>"
  28.  
  29.     Set oFDMgt   = Server.CreateObject("ASPPW.FDMgt")
  30.     iReturnCode  = oFDMgt.CopyFileEx (sDirOrg, sDirNew, "*.*")
  31.  
  32.     if iReturnCode = -1 then
  33.         response.write "Operation failed.<br>"
  34.         if oFDMgt.GetLastErrNum <> 0 then
  35.             response.write  oFDMgt.GetLastErrDescription & "<br>."
  36.         end if
  37.     elseif  iReturnCode = 0 then
  38.         response.write "Directory """ & sDirOrg & " not found.<br>"
  39.     else
  40.         response.write "Operation succeeds.<br>"
  41.     end if
  42.  
  43.     'Method: CopyFile(strSrcPathName, strTrgtPathName)
  44.     '
  45.     'Sample Operation:
  46.     'Copy file sample.txt in directory of DirOrg to "c:\".
  47.  
  48.     sSrcPathName   = "DirOrg\sample.txt"
  49.     sTrgtPathName  = "c:\me.txt"
  50.     sSrcPathName   = Server.MapPath("/") & "\" & sSrcPathName
  51.  
  52.     response.write "File """ & sSrcPathName &  """ will be copied as """ & sTrgtPathName & """.<br>"
  53.  
  54.     iReturnCode  = oFDMgt.CopyFile (sSrcPathName, sTrgtPathName)
  55.  
  56.     if iReturnCode = -1 then
  57.         response.write "Operation failed."
  58.         if oFDMgt.GetLastErrNum <> 0 then
  59.             response.write  oFDMgt.GetLastErrDescription
  60.         end if
  61.     elseif  iReturnCode = 0 then
  62.         response.write "File """ & sSrcPathName & " not found.<br>"
  63.     else
  64.         response.write "Operation succeeds."
  65.     end if
  66.     
  67.     Set oFDMgt   =  nothing
  68. %>
  69. </BODY></HTML>
  70.  
  71.  
  72.  
  73.  
  74.  
  75.