Scripting Runtime Library(FileSystemObject)
°æ·ÎÀÇ ¸¶Áö¸· ±¸¼º ¿ä¼Ò¿¡ ÇØ´çÇÏ´Â È®ÀåÀÚ ¹®ÀÚ¿À» ¹ÝȯÇÑ´Ù.
¹Ýȯ°ª sExtensionÀº objPath·Î ÁöÁ¤µÈ À§Ä¡ÀÇ ÆÄÀÏ È®ÀåÀÚ¸¦ ³ªÅ¸³»´Â ¹®ÀÚ¿ÀÌ´Ù.
°æ·ÎÀÇ ¸¶Áö¸· ±¸¼º ¿ä¼Ò¿¡ ÇØ´çÇÏ´Â È®ÀåÀÚ ¹®ÀÚ¿À» ¹ÝȯÇÑ´Ù.
³×Æ®¿öÅ© µå¶óÀ̺êÀÇ °æ¿ì ·çÆ® µð·ºÅ͸®(\)´Â ÇϳªÀÇ ±¸¼º ¿ä¼ÒÀÌ´Ù.
objPath Àμö¿Í ÀÏÄ¡ÇÏ´Â ±¸¼º ¿ä¼Ò°¡ ¾øÀ¸¸é GetExtensionName ¸Þ¼µå´Â ºó ¹®ÀÚ¿("")À» ¹ÝȯÇÑ´Ù.
<SCRIPT language=JScript> function GetExtensionNameTest(filePath){ var fso,str=''; fso=new ActiveXObject('Scripting.FileSystemObject'); folderObj=fso.GetFolder(filePath); enumObj=new Enumerator(folderObj.Files); for (; !enumObj.atEnd(); enumObj.moveNext()){ fileObj=enumObj.item(); str+=fileObj.Path+' : '+fso.GetExtensionName(fileObj)+'<BR>'; } return(str); } </SCRIPT> <DIV id=showjs class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV> <DIV class=show onClick="id=showjs.innerHTML=GetExtensionNameTest('C:\\JsTest')"> <SPAN class=ie>JScript</SPAN> C:\\JsTest <SPAN class=method>GetExtensionName</SPAN> ¸Þ¼µå ¿¹Á¦</DIV> <DIV class=show onClick="id=showjs.innerHTML=GetExtensionNameTest('C:\\My Documents')"> <SPAN class=ie>JScript</SPAN> C:\\My Documents <SPAN class=method>GetExtensionName</SPAN> ¸Þ¼µå ¿¹Á¦</DIV>
<SCRIPT language=VBScript> Function GetExtensionNameTestvb(folderPath) Dim fso str="" Set fso=CreateObject("Scripting.FileSystemObject") Set folderObj=fso.GetFolder(folderPath) Set filesCol=folderObj.Files For Each fileObj in filesCol str=str&fileObj.Path&" : "&fso.GetExtensionName(fileObj)&"<BR>" Next GetExtensionNameTestvb=str End Function </SCRIPT> <DIV id=showvb class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV> <DIV class=show onClick="showvb.innerHTML=GetExtensionNameTestvb('C:\\JsTest')"> <SPAN class=ie>VBScript</SPAN> C:\\JsTest <SPAN class=method>GetExtensionName</SPAN> ¸Þ¼µå ¿¹Á¦</DIV> <DIV class=show onClick="showvb.innerHTML=GetExtensionNameTestvb('C:\\My Documents')"> <SPAN class=ie>VBScript</SPAN> C:\\My Documents <SPAN class=method>GetExtensionName</SPAN> ¸Þ¼µå ¿¹Á¦</DIV>