Scripting Runtime Library(FileSystemObject)

ÁöÁ¤ÇÑ ÆÄÀÏÀ» »èÁ¦ÇÑ´Ù.

Àμö/ÆĶó¸ÞÅÍ
objectName
ÇʼöÀûÀÎ ¿ä¼ÒÀ̸ç, Ç×»ó FileSystemObjectÀÇ À̸§ÀÌ´Ù.
filePath
ÇʼöÀûÀÎ ¿ä¼ÒÀ̸ç, »èÁ¦ÇÒ ÆÄÀÏÀÇ À̸§ÀÌ´Ù.
filePathÀº ¸¶Áö¸· °æ·Î ±¸¼º ¿ä¼Ò¿¡ ¿ÍÀϵåÄ«µå ¹®ÀÚ¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù.
force
¼±ÅÃÀûÀÎ ¿ä¼ÒÀ̸ç, trueÀ̸é Àбâ Àü¿ë Ư¼º ÁýÇÕÀ» °¡Áø ÆÄÀÏÀ» »èÁ¦ÇÏ°í,
falseÀÌ¸é »èÁ¦ÇÏÁö ¾Ê´Â ºÎ¿ï°ªÀÌ´Ù.
¼³¸í

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

DeleteFile ¸Þ¼­µå´Â ù ¹ø° ¿À·ù°¡ ¹ß»ýÇÏ¸é ±× »óÅ·ΠÁßÁöÇÑ´Ù.
À̶§ ¿À·ù°¡ ¹ß»ýÇϱâ Àü¿¡ º¯°æµÈ »çÇ×Àº µÇµ¹¸± ¼ö ¾ø´Ù.

Delete ¸Þ¼­µå·Îµµ »èÁ¦ ÇÒ ¼ö ÀÖ´Ù.


DeleteFile ¸Þ¼­µå ¿¹Á¦

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

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

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