FileSystemObject(FSO) °³Ã¼ ¸ðµ¨À» »ç¿ëÇϸé Windows Ž»ö±â¿¡¼ ´ëÈÇüÀ¸·Î ÇÒ ¼ö ÀÖ´Â ÀÛ¾÷ó·³ ÇÁ·Î±×·¥¿¡¼ µå¶óÀ̺꿡 Á¢¼ÓÇÒ ¼ö ÀÖ´Ù.
Drive °³Ã¼¸¦ »ç¿ëÇÏ¸é ½ÇÁ¦·Î ¶Ç´Â ³×Æ®¿öÅ©¸¦ ÅëÇØ ½Ã½ºÅÛ¿¡ ¿¬°áµÇ¾î ÀÖ´Â ´Ù¾çÇÑ µå¶óÀ̺꿡 °üÇÑ Á¤º¸¸¦ º¼ ¼ö ÀÖ´Ù. ÀÌ °³Ã¼ÀÇ ¼Ó¼ºÀ» »ç¿ëÇÏ¸é ¾Æ·¡¿Í °°Àº Á¤º¸¸¦ º¼ ¼ö ÀÖ´Ù.
¿¹Á¦ Äڵ带 º¸¸é FileSystemObject¿¡¼ ÀÌ·± ¼Ó¼ºÀ» »ç¿ëÇÏ´Â ¹æ¹ýÀ» ¾Ë ¼ö ÀÖ´Ù.
Drive °³Ã¼´Â µå¶óÀ̺꿡 °üÇÑ Á¤º¸¸¦ ¸ðÀ¸´Â µ¥ »ç¿ëÇÑ´Ù.¿¹Á¦¿¡¼´Â ½ÇÁ¦ Drive °³Ã¼¿¡ ´ëÇÑ ÂüÁ¶°¡ ¾ø´Â ´ë½Å GetDrive ¸Þ¼µå¸¦ »ç¿ëÇÏ¿© ±âÁ¸ Drive °³Ã¼¿¡ ´ëÇÑ ÂüÁ¶¸¦ °¡Á®¿Â´Ù.
<SCRIPT language=JScript> function ShowDriveInfo1(drivePath){ var fso,driveObj,str=''; fso=new ActiveXObject('Scripting.FileSystemObject'); driveObj=fso.GetDrive(fso.GetDriveName(drivePath)); // Äõ¸®¿¡ »ç¿ëÇÒ File °³Ã¼¸¦ °¡Á®¿Â´Ù. str+='µå¶óÀ̺ê '+drivePath.toUpperCase()+' - '; str+=drivePath.VolumeName+'<BR>'; return str; } </SCRIPT>
<SCRIPT language=VBScript> Function DrivesTestvb(drivePath) Dim fso,driveObj,str Set fso=CreateObject("Scripting.FileSystemObject") Set driveObj=fso.GetDrive(fso.GetDriveName(drivePath)); // Äõ¸®¿¡ »ç¿ëÇÒ File °³Ã¼¸¦ °¡Á®¿Â´Ù. str="µå¶óÀ̺ê "&UCase(drivePath)&" - " str=str&driveObj.VolumeName&"<BR>" DrivesTestvb=str End Function </SCRIPT> <DIV id=showvb class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV> <DIV class=show onClick="showvb.innerHTML=DrivesTestvb('b')">VBScript <SPAN class=method>Drives</SPAN>
¾Æ·¡ Ç¥¿¡´Â ÀϹÝÀûÀÎ Æú´õ ÀÛ¾÷°ú ÀÌ·± ÀÛ¾÷¿¡ »ç¿ëµÇ´Â ¸Þ¼µå°¡ ¼³¸íµÇ¾î ÀÖ´Ù.
ÀÛ¾÷ | ¸Þ¼µå |
---|---|
Æú´õ¸¦ ¸¸µç´Ù. | FileSystemObject.CreateFolder |
Æú´õ¸¦ »èÁ¦ÇÑ´Ù. | Folder.Delete ¶Ç´Â FileSystemObject.DeleteFolder |
Æú´õ¸¦ À̵¿ÇÑ´Ù. | Folder.Move ¶Ç´Â FileSystemObject.MoveFolder |
Æú´õ¸¦ º¹»çÇÑ´Ù. | Folder.Copy ¶Ç´Â FileSystemObject.CopyFolder |
Æú´õ À̸§À» °Ë»öÇÑ´Ù. | Folder.Name |
µå¶óÀ̺꿡¼ Æú´õÀÇ Á¸À縦 ã´Â´Ù. | FileSystemObject.FolderExists |
±âÁ¸ Folder °³Ã¼ÀÇ ÀνºÅϽº¸¦ °¡Á®¿Â´Ù. | FileSystemObject.GetFolder |
Æú´õÀÇ »óÀ§ Æú´õ À̸§À» ã´Â´Ù. | FileSystemObject.GetParentFolderName |
½Ã½ºÅÛ Æú´õÀÇ °æ·Î¸¦ ã´Â´Ù. | FileSystemObject.GetSpecialFolder |
¿¹Á¦ Äڵ带 º¸¸é FileSystemObject¿¡¼ »ç¿ëµÇ´Â ¸Þ¼µå ¼ö¿Í ¼Ó¼º ¼ö¸¦ ¾Ë ¼ö ÀÖ´Ù.
¾Æ·¡ ¿¹Á¦´Â Æú´õ¸¦ Á¶ÀÛÇÏ°í Á¤º¸¸¦ º¸´Â ¹æ¹ýÀ» º¸¿©ÁØ´Ù.
<SCRIPT language=JScript> function ShowFolderInfo(folderPath){ var fso, folderObj; str=''; fso=new ActiveXObject('Scripting.FileSystemObject'); // FileSystemObjectÀÇ ÀνºÅϽº¸¦ °¡Á®¿Â´Ù. folderObj=fso.GetFolder('c:\\'); // »óÀ§ Æú´õ À̸§À» Ãâ·ÂÇÑ´Ù. str+='»óÀ§ Æú´õ À̸§ : '+folderObj+'<BR>'; // µå¶óÀ̺ê À̸§À» Ãâ·ÂÇÑ´Ù. str+='µå¶óÀ̺ê À̸§ : '+folderObj.Drive+'<BR>'; // ·çÆ® ÆÄÀÏ À̸§À» Ãâ·ÂÇÑ´Ù. if (folderObj.IsRootFolder) str+=folderObj+'´Â ·çÆ® Æú´õÀÌ´Ù.'; else str+=folderObj+'´Â ·çÆ® Æú´õ°¡ ¾Æ´Ï´Ù'; str+='<BR><BR>'; if (fso.FolderExists(folderPath)){ newObj=fso.GetFolder(folderPath) str+=folderPath+"°¡ Á¸ÀçÇÑ´Ù.<BR>" fso.DeleteFolder(folderPath) str+=folderPath+"¸¦ »èÁ¦Çß´Ù.<BR>" } newObj=fso.CreateFolder(folderPath); // FileSystemObject °³Ã¼¿¡ »õ Æú´õ¸¦ ¸¸µç´Ù. folderObj=fso.GetFolder(fso.GetDriveName(newObj)); // Drive °³Ã¼¸¦ °¡Á®¿Â´Ù. str+='¸¸µç Æú´õ = '+newObj+'<BR>'; // Æú´õÀÇ ±âº» À̸§À» Ãâ·ÂÇÑ´Ù. str+='±âº» À̸§ = '+fso.GetBaseName(newObj)+'<BR>'; str+='»óÀ§ Æú´õ À̸§ : 'newObj.ParentFolder+'
'; str+='µå¶óÀ̺ê À̸§ : '+fso.getFolder(newObj).Drive+'<BR>'; // ·çÆ® ÆÄÀÏ À̸§À» Ãâ·ÂÇÑ´Ù. if (newObj.IsRootFolder) str+=newObj+'´Â ·çÆ® Æú´õÀÌ´Ù.'; else str+=newObj+'´Â ·çÆ® Æú´õ°¡ ¾Æ´Ï´Ù.'; str+='<BR><BR>'; str+='»èÁ¦ÇÑ Æú´õ = '+newObj+'<BR>'; return str; fso.DeleteFolder(newObj); // »õ·Î ¸¸µç Æú´õ¸¦ »èÁ¦ÇÑ´Ù. } </SCRIPT> <DIV class=show onClick="this.innerHTML=ShowFolderInfo('c:\\JsTest\\TestFolder')">Ŭ¸¯(JScript)</DIV>
<SCRIPT language=VBScript> Function ShowFolderVB(folderPath) Dim fso, folderObj str="" Set fso=CreateObject("Scripting.FileSystemObject") ' FileSystemObjectÀÇ ÀνºÅϽº¸¦ °¡Á®¿Â´Ù. Set folderObj=fso.GetFolder("c:\") ' Drive °³Ã¼¸¦ °¡Á®¿Â´Ù. str=str&"»óÀ§ Æú´õ À̸§ : " & folderObj & "<BR>" ' »óÀ§ Æú´õ À̸§À» Ãâ·ÂÇÑ´Ù. str=str&"µå¶óÀ̺ê À̸§ : " & folderObj.Drive & "<BR>" ' µå¶óÀ̺ê À̸§À» Ãâ·ÂÇÑ´Ù. If folderObj.IsRootFolder=True Then ' ·çÆ® ÆÄÀÏ À̸§À» Ãâ·ÂÇÑ´Ù. str=str&folderObj&"´Â ·çÆ® Æú´õÀÌ´Ù." Else str=str&folderObj&"´Â ·çÆ® Æú´õ°¡ ¾Æ´Ï´Ù." End If str=str& "<BR><BR>" If fso.FolderExists(folderPath) Then newObj=fso.GetFolder(folderPath) str=str&folderPath&"°¡ Á¸ÀçÇÑ´Ù.<BR>" fso.DeleteFolder(folderPath) str=str&folderPath&"¸¦ »èÁ¦Çß´Ù.<BR>" End If newObj=fso.CreateFolder(folderPath) ' FileSystemObject °³Ã¼·Î »õ Æú´õ¸¦ ¸¸µç´Ù. Set folderObj=fso.GetFolder(newObj) ' Drive °³Ã¼¸¦ °¡Á®¿Â´Ù. str=str&"¸¸µç Æú´õ : "&newObj& "<BR>" str=str&"±âº» À̸§ : " &fso.GetBaseName(newObj) & "<BR>" ' Æú´õÀÇ ±âº» À̸§À» Ãâ·ÂÇÑ´Ù. str=str&"»óÀ§ Æú´õ À̸§ : " & folderObj & "<BR>" ' »óÀ§ Æú´õ À̸§À» Ãâ·ÂÇÑ´Ù. str=str&"µå¶óÀ̺ê À̸§ : " & folderObj.Drive & "<BR>" ' µå¶óÀ̺ê À̸§À» Ãâ·ÂÇÑ´Ù. If folderObj.IsRootFolder=True Then ' ·çÆ® ÆÄÀÏ À̸§À» Ãâ·ÂÇÑ´Ù. str=str&folderObj&"´Â ·çÆ® Æú´õÀÌ´Ù." Else str=str&folderObj&"´Â ·çÆ® Æú´õ°¡ ¾Æ´Ï´Ù." End If str=str& "<BR><BR>" fso.DeleteFolder (newObj) ' »õ·Î ¸¸µç Æú´õ¸¦ »èÁ¦ÇÑ´Ù. str=str&"»èÁ¦ÇÑ Æú´õ : "&newObj&"<BR>" DrivesTestvb=str End Function </SCRIPT> <DIV id=showvb class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV> <DIV class=show onClick="showvb.innerHTML=DrivesTestvb('b')">VBScript <SPAN class=method>Drives</SPAN><DIV id=show1 class=show onClick="this.innerHTML=ShowFolderVB('c:\\JsTest\\TestFolder')">Ŭ¸¯(VBScript)</DIV>