Scripting Runtime Library(FileSystemObject)

ÁöÁ¤ÇÑ ÆÄÀÏÀ̳ª Æú´õ¸¦ »èÁ¦ÇÑ´Ù.

Àμö/ÆĶó¸ÞÅÍ
objectName
ÇʼöÀûÀÎ ¿ä¼ÒÀ̸ç, Ç×»ó File ¶Ç´Â Folder °³Ã¼ÀÇ À̸§ÀÌ´Ù.
force
¼±ÅÃÀûÀÎ ¿ä¼ÒÀ̸ç, trueÀ̸é Àбâ Àü¿ë Ư¼º ÁýÇÕÀ» °¡Áø ÆÄÀÏÀ̳ª Æú´õ¸¦ »èÁ¦ÇÏ°í,
false(±âº»°ª)ÀÌ¸é »èÁ¦ÇÏÁö ¾Ê´Â ºÎ¿ï°ªÀÌ´Ù.
¹Ýȯ°ª

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

¼³¸í

ÁöÁ¤ÇÑ ÆÄÀÏÀ̳ª Æú´õ°¡ ¾øÀ¸¸é ¿À·ù°¡ ¹ß»ýÇÑ´Ù.

FileÀ̳ª Folder¿¡¼­ Delete ¸Þ¼­µå¸¦ »ç¿ëÇϸé FileSystemObject.DeleteFileÀ̳ª FileSystemObject.DeleteFolder¸¦ »ç¿ëÇÏ´Â °Í°ú µ¿ÀÏÇÑ °á°ú¸¦ ¾òÀ» ¼ö ÀÖ´Ù.

Delete ¸Þ¼­µå´Â ³»¿ëÀÌ ÀÖ´Â Æú´õ¿Í ³»¿ëÀÌ ¾ø´Â Æú´õ¸¦ ±¸ºÐÇÏÁö ¾Ê´Â´Ù.
ÁöÁ¤ÇÑ Æú´õ´Â ³»¿ëÀÌ ÀÖµç ¾øµç »èÁ¦µÈ´Ù. µû¶ó¼­ ÁÖÀÇÇÏ¿©¾ß ÇÑ´Ù.


Delete ¸Þ¼­µå ¿¹Á¦

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

  tempPath='C:\\JsTest\\DeletFolder';
  if (fso.FolderExists(tempPath)) fso.DeleteFolder(tempPath);
  fso.CreateFolder(tempPath);
  tempObj=fso.GetFolder(tempPath);
  str+='Æú´õ "'+tempPath+'"°¡ »ý¼ºµÇ¾ú´Ù.<BR>';
  tempObj.Delete();
  str+='Æú´õ "'+tempPath+'"°¡ »èÁ¦µÇ¾ú´Ù.';
  return(str);
}
</SCRIPT>

<DIV id=showjs class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV>
<DIV class=show
  onClick="showjs.innerHTML=DeleteTest('C:\\JsTest\\test\\testDelete.txt')">
  <SPAN class=ie>JScript</SPAN> <SPAN class=method>Delete</SPAN> ¸Þ¼­µå ¿¹Á¦</DIV>
°á°ú Ç¥½Ãâ
VBScript Delete ¸Þ¼­µå ¿¹Á¦
<SCRIPT language=VBScript>
Function DeleteTestvb(filePath)
  Dim fso,fileObj,tempPath,tempObj
  Set fso=CreateObject("Scripting.FileSystemObject")
  If fso.FileExists(filePath) Then
    fso.DeleteFile(filePath)
  End If
  Set fileObj=fso.CreateTextFile(filePath,True)
  fileObj.WriteLine "Å×½ºÆ®ÀÌ´Ù."
  fileObj.Close
  str="ÆÄÀÏ '"&filePath&"'°¡ »ý¼ºµÇ¾ú´Ù.<BR>"
  Set fileObj=fso.GetFile(filePath)
  fileObj.Delete
  str=str&"ÆÄÀÏ '"&filePath&"'°¡ »èÁ¦µÇ¾ú´Ù.<BR><BR>"

  tempPath="C:\\JsTest\DeletFolder"
  If fso.FolderExists(tempPath) Then
    fso.DeleteFolder(tempPath)
  End If
  fso.CreateFolder(tempPath)
  str=str&"Æú´õ '"&tempPath&"'°¡ »ý¼ºµÇ¾ú´Ù.<BR>"
  Set tempObj=fso.GetFolder(tempPath)
  tempObj.Delete
  str=str&"Æú´õ '"&tempPath&"'°¡ »èÁ¦µÇ¾ú´Ù.<BR>"
  DeleteTestvb=str
End Function
</SCRIPT>

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