Scripting Runtime Library(FileSystemObject)

ÁöÁ¤ÇÑ ÆÄÀÏÀ̳ª Æú´õ¸¦ ±âÁ¸ À§Ä¡¿¡¼­ ´Ù¸¥ À§Ä¡·Î º¹»çÇÑ´Ù.

Àμö/ÆĶó¸ÞÅÍ
objectName
ÇʼöÀûÀÎ ¿ä¼ÒÀ̸ç, Ç×»ó File ¶Ç´Â Folder °³Ã¼ÀÇ À̸§ÀÌ´Ù.
destination
ÇʼöÀûÀÎ ¿ä¼ÒÀ̸ç, ÆÄÀÏ ¶Ç´Â Æú´õ¸¦ º¹»çÇÒ À§Ä¡ÀÌ´Ù. ¿ÍÀϵåÄ«µå ¹®ÀÚ´Â »ç¿ëÇÒ ¼ö ¾ø´Ù.
overwrite
¼±ÅÃÀûÀÎ ¿ä¼ÒÀ̸ç, true(±âº»°ª)ÀÌ¸é ±âÁ¸ ÆÄÀÏÀ̳ª Æú´õ¸¦ µ¤¾î¾²°í falseÀÌ¸é µ¤¾î¾²Áö ¾Ê´Â ºÎ¿ï°ªÀÌ´Ù.
¹Ýȯ°ª

¹Ýȯ°ªÀº ¾ø´Ù.

¼³¸í

ÁöÁ¤ÇÑ ÆÄÀÏÀ̳ª Æú´õ¸¦ ±âÁ¸ À§Ä¡¿¡¼­ ´Ù¸¥ À§Ä¡·Î º¹»çÇÑ´Ù.

FileÀ̳ª Folder¿¡ Copy ¸Þ¼­µå¸¦ »ç¿ëÇϸé objectName¿¡ ÀÇÇØ ÂüÁ¶µÇ´Â ÆÄÀÏÀ̳ª Æú´õ¸¦ Àμö·Î Àü´ÞÇÏ´Â FileSystemObject.CopyFileÀ̳ª FileSystemObject.CopyFolder¸¦ »ç¿ëÇÑ °á°ú¿Í µ¿ÀÏÇÏ´Ù.

ÀÌ·± ´ëü ¸Þ¼­µå¸¦ »ç¿ëÇϸé ÆÄÀÏÀ̳ª Æú´õ¸¦ Çѹø¿¡ ¿©·¯ °³ º¹»çÇÒ ¼ö ÀÖ´Ù.


Copy ¸Þ¼­µå ¿¹Á¦

°á°ú Ç¥½Ãâ
JScript Copy ¸Þ¼­µå ¿¹Á¦
<SCRIPT language=JScript>
function CopyTest(filePath,destination){
  var fso,fileObj,str='';
  fso=new ActiveXObject('Scripting.FileSystemObject');
  fileObj=fso.CreateTextFile(filePath,true);
  fileObj.WriteLine('Å×½ºÆ®ÀÌ´Ù.');
  fileObj.Close();
  fileObj=fso.GetFile(filePath);
  fileObj.Copy(destination);
  str+='»ý¼ºµÈ ÆÄÀÏ "'+filePath+'"°¡<BR>"'+destination+'"À¸·Î º¹»çµÇ¾ú´Ù.<BR><BR>';

  folderObj=fso.GetFolder('c:\\JsTest\\test');
  newPath='c:\\JsTest\\CopyTest';
  if (!fso.FolderExists(newPath)) fso.CreateFolder(newPath);
  folderObj.Copy(newPath,true);
  str+='Æú´õ "'+folderObj+'"°¡ "'+newPath+'"À¸·Î º¹»çµÇ¾ú´Ù.';
  return(str);
}
</SCRIPT>

<DIV id=showjs class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV>
<DIV class=show
  onClick="showjs.innerHTML=
    CopyTest('C:\\JsTest\\test\\testfile.txt','C:\\JsTest\\test\\testcopy.txt')">
  <SPAN class=ie>JScript</SPAN> <SPAN class=method>Copy</SPAN> ¸Þ¼­µå ¿¹Á¦</DIV>
°á°ú Ç¥½Ãâ
VBScript Copy ¸Þ¼­µå ¿¹Á¦
<SCRIPT language=VBScript>
Function CopyTestvb(filePath,destination)
  Dim fso,fileObj,folderObj,newPath
  str=""
  Set fso=CreateObject("Scripting.FileSystemObject")
  Set fileObj=fso.CreateTextFile(filePath,True)
  fileObj.WriteLine("Å×½ºÆ®ÀÌ´Ù.")
  fileObj.Close
  Set fileObj=fso.GetFile(filePath)
  fileObj.Copy(destination)
  str=str&"»ý¼ºµÈ ÆÄÀÏ='"&filePath&"'°¡<BR>'"&destination&"'·Î º¹»çµÇ¾ú´Ù.<BR><BR>"

  Set folderObj=fso.GetFolder("c:\JsTest\test")
  newPath="c:\\JsTest\\CopyTest"
  If Not fso.FolderExists(newPath) Then
    fso.CreateFolder(newPath)
  End If
  folderObj.Copy(newPath)
  str=str&"Æú´õ '"&folderObj&"'°¡ '"&newPath&"'À¸·Î º¹»çµÇ¾ú´Ù."
  CopyTestvb=str
End Function
</SCRIPT>

<DIV id=showvb class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV>
<DIV class=show
  onClick="showvb.innerHTML=
    CopyTestvb('C:\\JsTest\\test\\testfile.txt','C:\\JsTest\\test\\testcopy.txt')">
  <SPAN class=ie>VBScript</SPAN> <SPAN class=method>Copy</SPAN> ¸Þ¼­µå ¿¹Á¦</DIV>