Scripting Runtime Library(FileSystemObject)

Çϳª ÀÌ»óÀÇ ÆÄÀÏÀ» ±âÁ¸ À§Ä¡¿¡¼­ ´Ù¸¥ À§Ä¡·Î º¹»çÇÑ´Ù.

Àμö/ÆĶó¸ÞÅÍ
objectName
ÇʼöÀûÀÎ ¿ä¼ÒÀ̸ç, objectName´Â Ç×»ó FileSystemObjectÀÇ À̸§ÀÌ´Ù.
source
ÇʼöÀûÀÎ ¿ä¼ÒÀ̸ç, º¹»çÇÒ Çϳª ÀÌ»óÀÇ ÆÄÀÏ¿¡ ´ëÇÑ ¹®ÀÚ¿­ ÆÄÀÏÀÌ´Ù. ¿ÍÀϵåÄ«µå ¹®ÀÚ¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù.

¿ÍÀϵåÄ«µå ¹®ÀÚ(*)´Â source ÀμöÀÇ ¸¶Áö¸· °æ·Î ±¸¼º ¿ä¼Ò¿¡¸¸ »ç¿ëÇÒ ¼ö ÀÖ´Ù.

destination
ÇʼöÀûÀÎ ¿ä¼ÒÀ̸ç, sourceÀÇ ÆÄÀÏÀ» º¹»çÇÒ ¹®ÀÚ¿­ ´ë»óÀÌ´Ù. ¿ÍÀϵåÄ«µå ¹®ÀÚ´Â »ç¿ëÇÒ ¼ö ¾ø´Ù.
overwrite
¼±ÅÃÀûÀÎ ¿ä¼ÒÀ̸ç, ±âÁ¸ ÆÄÀÏÀ» µ¤¾î¾µÁö ¿©ºÎ¸¦ ³ªÅ¸³»´Â ºÎ¿ï°ªÀÌ´Ù. ºÎ¿ï°ªÀÌ trueÀ̸é ÆÄÀÏÀ» µ¤¾î¾²°í, falseÀÌ¸é µ¤¾î¾²Áö ¾Ê´Â´Ù. ±âº»°ªÀº trueÀÌ´Ù.

overwrite °ª¿¡ °ü°è¾øÀÌ destinationÀÌ Àбâ Àü¿ë Ư¼º ÁýÇÕÀ» °¡Áö¸é CopyFileÀº ¼öÇàÇÒ ¼ö ¾ø´Ù.

¹Ýȯ°ª

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

¼³¸í

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

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

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

source¿¡ ¿ÍÀϵåÄ«µå ¹®ÀÚ¸¦ »ç¿ëÇϰųª destinationÀÌ °æ·Î ±¸ºÐ ±âÈ£(\)·Î ³¡³ª¸é destinationÀº ÀÏÄ¡ÇÏ´Â ÆÄÀÏÀ» º¹»çÇÒ ±âÁ¸ Æú´õ¸¦ ³ªÅ¸³½´Ù.
±×·¸Áö ¾ÊÀ¸¸é destinationÀº ¸¸µé·Á´Â ÆÄÀÏÀÇ À̸§À» ³ªÅ¸³½´Ù.
µÑ Áß ¾î´À °æ¿ì¶óµµ °³º° ÆÄÀÏÀ» º¹»çÇÒ ¶§ ¾Æ·¡ ¼¼ °¡Áö Áß Çϳª°¡ ÀϾ ¼ö ÀÖ´Ù.

¿ÍÀϵåÄ«µå ¹®ÀÚ¸¦ »ç¿ëÇÑ source¿Í ÀÏÄ¡ÇÏ´Â ÆÄÀÏÀÌ ¾øÀ¸¸é ¿À·ù°¡ ¹ß»ýÇÑ´Ù.
CopyFile ¸Þ¼­µå´Â ù ¹ø° ¿À·ù°¡ ¹ß»ýÇÏ¸é ±× »óÅ·ΠÁßÁöÇÑ´Ù.
À̶§ ¿À·ù°¡ ¹ß»ýÇϱâ Àü¿¡ º¯°æµÈ »çÇ×Àº µÇµ¹¸± ¼ö ¾ø´Ù.


CopyFile ¸Þ¼­µå ¿¹Á¦

°á°ú Ç¥½Ãâ
JScript CopyFile ¸Þ¼­µå ¿¹Á¦
<SCRIPT language=JScript>
function CopyFileTest(source,destination){
  fso=new ActiveXObject('Scripting.FileSystemObject');
  fso.CopyFile(source,destination,true);
  str='"'+source+'"°¡ "'+destination+'"À¸·Î º¹»çµÇ¾ú´Ù.';
  return(str);
}
</SCRIPT>

<DIV id=showjs class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV>
<DIV class=show
  onClick="showjs.innerHTML=
    CopyFileTest('C:\\JsTest\\test\\*.txt','C:\\JsTest\\CopyFiletest\\')">
  <SPAN class=ie>JScript</SPAN> <SPAN class=method>CopyFile</SPAN> ¸Þ¼­µå ¿¹Á¦</DIV>
°á°ú Ç¥½Ãâ
VBScript CopyFile ¸Þ¼­µå ¿¹Á¦
<SCRIPT language=VBScript>
Function CopyFileTestvb(source,destination)
  Dim fso,fileObj
  Set fso=CreateObject("Scripting.FileSystemObject")
  fso.CopyFile source,destination
  str="'"&source&"'°¡ '"&destination&"'À¸·Î º¹»çµÇ¾ú´Ù."
  CopyFileTestvb=str
End Function
</SCRIPT>

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

±×·¯³ª ´ÙÀ½°ú °°ÀÌ »ç¿ëÇÒ ¼ö´Â ¾ø´Ù.

<SCRIPT language=JScript>
fso=new ActiveXObject("Scripting.FileSystemObject");
fso.CopyFile("c:\\mydocuments\\*\\R1???97.xls","c:\\tempfolder")
</SCRIPT>
<SCRIPT language=VBScript>
FileSystemObject.CopyFile "c:\mydocuments\*\R1???97.xls","c:\tempfolder"
</SCRIPT>