Scripting Runtime Library(FileSystemObject)
µå¶óÀ̺êÀÇ ÀϺκÐÀÌ ¾Æ´Ñ ÁöÁ¤ÇÑ °æ·ÎÀÇ ¸¶Áö¸· ±¸¼º ¿ä¼Ò¸¦ ¹ÝȯÇÑ´Ù.
¹Ýȯ°ª sName´Â filePath·Î ÁöÁ¤µÈ À§Ä¡ÀÇ ÆÄÀÏÀÇ À̸§À» ³ªÅ¸³»´Â ¹®ÀÚ¿ÀÌ´Ù.
µå¶óÀ̺êÀÇ ÀϺκÐÀÌ ¾Æ´Ñ ÁöÁ¤ÇÑ °æ·ÎÀÇ ¸¶Áö¸· ±¸¼º ¿ä¼Ò¸¦ ¹ÝȯÇÑ´Ù.
filePathÀÌ ¸í¸íµÈ ±¸¼º ¿ä¼Ò·Î ³¡³ªÁö ¾ÊÀ¸¸é GetFileName ¸Þ¼µå´Â ºó ¹®ÀÚ¿("")À» ¹ÝȯÇÑ´Ù.
Âü°í: GetFileName ¸Þ¼µå´Â ÁÖ¾îÁø °æ·Î ¹®ÀÚ¿¿¡¸¸ »ç¿ëÇÑ´Ù.
°æ·Î¸¦ °áÁ¤ÇÏÁöµµ ¾Ê°í ÁöÁ¤ÇÑ °æ·Î°¡ ÀÖ´ÂÁöµµ °Ë»çÇÏÁö ¾Ê´Â´Ù.
<SCRIPT language=JScript> function GetFileNameTest(filePath){ var fso,str=''; fso=new ActiveXObject('Scripting.FileSystemObject'); if (!fso.FileExists(filePath)){ fileObj=fso.OpenTextFile(filePath,2,true); fileObj.WriteLine('¿¹Á¦¸¦ À§ÇÑ ÆÄÀÏÀÌ´Ù.'); fileObj.Close(); } str+=filePath+' : '+fso.GetFileName(filePath); return(str); } </SCRIPT> <DIV id=showjs class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV> <DIV class=show onClick="showjs.innerHTML=GetFileNameTest('C:\\JsTest\\CreateText.txt')"> <SPAN class=ie>JScript</SPAN> <SPAN class=method>GetFileName</SPAN> ¸Þ¼µå ¿¹Á¦</DIV>
<SCRIPT language=VBScript> Function GetFileNameTestvb(filePath) Dim fso Set fso=CreateObject("Scripting.FileSystemObject") If Not fso.FileExists(filePath) Then Set fileObj=fso.OpenTextFile(filePath,2,True) fileObj.Write "¿¹Á¦¸¦ À§ÇÑ ÆÄÀÏÀÌ´Ù." fileObj.Close End If str=filePath&" : "&fso.GetFileName(filePath) GetFileNameTestvb=str End Function </SCRIPT> <DIV id=showvb class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV> <DIV class=show onClick="showvb.innerHTML=GetFileNameTestvb('C:\\JsTest\\CreateText.txt')"> <SPAN class=ie>VBScript</SPAN> <SPAN class=method>GetFileName</SPAN> ¸Þ¼µå ¿¹Á¦</DIV>