Scripting Runtime Library(FileSystemObject)
Çϳª ÀÌ»óÀÇ ÆÄÀÏÀ» ±âÁ¸ À§Ä¡¿¡¼ ´Ù¸¥ À§Ä¡·Î ¿Å±ä´Ù.
¹Ýȯ°ªÀº ¾ø´Ù.
Çϳª ÀÌ»óÀÇ ÆÄÀÏÀ» ±âÁ¸ À§Ä¡¿¡¼ ´Ù¸¥ À§Ä¡·Î ¿Å±ä´Ù.
source¿¡ ¿ÍÀϵåÄ«µå¸¦ »ç¿ëÇϰųª destinationÀÌ °æ·Î ±¸ºÐ ±âÈ£(\)·Î ³¡³ª¸é destinationÀÌ ÀÏÄ¡ÇÏ´Â ÆÄÀÏÀ» ¿Å±æ ±âÁ¸ Æú´õ(Folder)¸¦ ³ªÅ¸³½´Ù.
±×·¸Áö ¾ÊÀ¸¸é destinationÀº ¸¸µé ´ë»ó ÆÄÀÏ(File)ÀÇ À̸§À» ³ªÅ¸³½´Ù.
µÑ Áß ¾î´À °æ¿ì¶óµµ °³º° ÆÄÀÏÀ» ¿Å±æ ¶§ ¾Æ·¡ ¼¼ °¡Áö Áß Çϳª°¡ ÀϾ ¼ö ÀÖ´Ù.
source¿¡ »ç¿ëÇÑ ¿ÍÀϵåÄ«µå ¹®ÀÚ¿Í ÀÏÄ¡ÇÏ´Â ÆÄÀÏÀÌ ¾øÀ¸¸é ¿À·ù°¡ ¹ß»ýÇÑ´Ù.
MoveFile ¸Þ¼µå´Â ù ¹ø° ¿À·ù°¡ ¹ß»ýÇÏ¸é ±× »óÅ·ΠÁßÁöÇÑ´Ù.
¿À·ù°¡ ¹ß»ýÇÏ°í ³ª¸é ÀÌÀü¿¡ º¯°æµÈ »çÇ×Àº µÇµ¹¸± ¼ö ¾ø´Ù.
Âü°í: ¿î¿µ üÁ¦°¡ Áö¿øÇÏ´Â °æ¿ì¿¡¸¸ ÀÌ ¸Þ¼µå¸¦ »ç¿ëÇÏ¿© º¼·ýµé °£¿¡ ÆÄÀÏÀ» ¿Å±æ ¼ö ÀÖ´Ù.
<SCRIPT language=JScript> function MoveFileTest(filePath,destination){ str=''; var fso=new ActiveXObject('Scripting.FileSystemObject'); if (!fso.FileExists(filePath)){ fileObj=fso.OpenTextFile(filePath,2,true); fileObj.WriteLine('¿¹Á¦¸¦ À§ÇÑ ÆÄÀÏÀÌ´Ù.'); fileObj.Close(); str+='¿øº» ÆÄÀÏÀÌ ¾ø¾î '+filePath+' ÆÄÀÏÀ» »ý¼ºÇÏ¿´´Ù.<BR>'; } if (!fso.FolderExists(destination)){ fso.CreateFolder(destination); str+='º¹»ç Æú´õ°¡ ¾ø¾î '+destination+' Æú´õ¸¦ »ý¼ºÇÏ¿´´Ù.<BR>'; } targetFile=destination+'\\'+fso.GetFileName(filePath); if (fso.FileExists(targetFile)){ fso.DeleteFile(targetFile); str+='º¹»ç ÆÄÀÏÀÌ ÀÖ¾î '+targetFile+' ÆÄÀÏÀ» »èÁ¦ÇÏ¿´´Ù.<BR>'; } fso.MoveFile(filePath,destination); str+='¿øº» '+filePath+' ÆÄÀÏÀ» '+destination+'À¸·Î À̵¿ÇÏ¿´´Ù.'; return(str); } </SCRIPT> <DIV id=showjs class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV> <DIV class=show onClick="id=showjs.innerHTML=MoveFileTest('C:\\JsTest\\CreateText.txt','C:\\JsTest\\test\\')"> <SPAN class=ie>JScript</SPAN> <SPAN class=method>MoveFile</SPAN> ¸Þ¼µå ¿¹Á¦</DIV>
<SCRIPT language=VBScript> Function MoveFileTestvb(filePath,destination) Dim fso,targetFile str="" Set fso=CreateObject("Scripting.FileSystemObject") If Not fso.FileExists(filePath) Then Set fileObj=fso.OpenTextFile(filePath,2,True) fileObj.WriteLine "¿¹Á¦¸¦ À§ÇÑ ÆÄÀÏÀÌ´Ù." fileObj.Close str=str&"¿øº» ÆÄÀÏÀÌ ¾ø¾î "&filePath&" ÆÄÀÏÀ» »ý¼ºÇÏ¿´´Ù.<BR>" End If If Not fso.FolderExists(destination) Then fso.CreateFolder(destination) str=str&"º¹»ç Æú´õ°¡ ¾ø¾î "&destination&" Æú´õ¸¦ »ý¼ºÇÏ¿´´Ù.<BR>" End If targetFile=destination&"\"&fso.GetFileName(filePath) If fso.FileExists(targetFile) Then fso.DeleteFile(targetFile) str=str&"º¹»ç ÆÄÀÏÀÌ ÀÖ¾î "&targetFile&" ÆÄÀÏÀ» »èÁ¦ÇÏ¿´´Ù.<BR>" End If fso.MoveFile drivePath,destination str=str&"¿øº» "&filePath&" ÆÄÀÏÀ» "&destination&"À¸·Î À̵¿ÇÏ¿´´Ù." MoveFileTestvb=str End Function </SCRIPT> <DIV id=showvb class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV> <DIV class=show onClick="showvb.innerHTML=MoveFileTestvb('C:\\JsTest\\CreateText.txt','C:\\JsTest\\test\\')"> <SPAN class=ie>VBScript</SPAN> <SPAN class=method>MoveFile</SPAN> ¸Þ¼µå ¿¹Á¦</DIV>