Scripting Runtime Library(TextStream)

TextStream ÆÄÀÏ Àüü¸¦ ÀÐ°í °á°ú·Î ³ª¿À´Â ¹®ÀÚ¿­À» ¹ÝȯÇÑ´Ù.

Àμö/ÆĶó¸ÞÅÍ
object
ÇʼöÀûÀÎ ¿ä¼ÒÀ̸ç, Ç×»ó TextStream °³Ã¼ÀÇ À̸§ÀÌ´Ù.
ÆĶó¸ÞÅÍ
ÆĶó¸ÞÅÍ´Â ¾ø´Ù.
¹Ýȯ°ª

¹Ýȯ°ª sValÀº TextStream ÆÄÀÏ Àüü¸¦ ÀÐ°í °á°ú·Î ³ª¿À´Â ¹®ÀÚ¿­À» ¹ÝȯÇÑ´Ù.

¼³¸í

¿ë·®ÀÌ Å« ÆÄÀÏ¿¡¼­ ReadAll ¸Þ¼­µå¸¦ »ç¿ëÇÏ¸é ¸Þ¸ð¸® ¸®¼Ò½º¸¦ ³¶ºñÇÏ°Ô µÈ´Ù.
ÇÑ ÁÙ¾¿ ÆÄÀÏ Àбâ¿Í °°Àº ´Ù¸¥ ±â¼úÀ» »ç¿ëÇÏ´Â °ÍÀÌ ÁÁ´Ù.


ReadAll ¸Þ¼­µå ¿¹Á¦

°á°ú Ç¥½Ãâ
JScript ReadAll ¸Þ¼­µå ¿¹Á¦
<SCRIPT language=JScript>
function ReadAllTest(filePath){
  var fso,fileObj,str='';
  var ForReading=1,ForWriting=2;
  fso=new ActiveXObject('Scripting.FileSystemObject');
  if (fso.FileExists(filePath)) fso.DeleteFile(filePath);
  fileObj=fso.OpenTextFile(filePath,ForWriting,true);
  fileObj.WriteLine('¿¹Á¦¸¦ À§ÇÑ ÆÄÀÏÀÌ´Ù.');
  fileObj.WriteLine('1234567890987654321');
  fileObj.WriteLine('ABCDEFGHIJKLMNOPQRSTUVWXYZ');
  fileObj.Close();
  str+='¿¹Á¦¸¦ À§ÇÑ  '+filePath+' ÆÄÀÏÀ» »ý¼ºÇÏ¿´´Ù.<BR><BR>';

  fileObj=fso.OpenTextFile(filePath,ForReading);
  str+='fileObj.Read(10)='+fileObj.Read(10)+'<BR>';
  str+='fileObj.ReadLine()='+fileObj.ReadLine()+'<BR>';
  str+='fileObj.ReadAll='+fileObj.ReadAll()+'<BR><BR>';

  fileObj=fso.OpenTextFile(filePath,ForReading);
  str+='fileObj.ReadAll='+fileObj.ReadAll();
  return(str);
}
</SCRIPT>

<DIV id=showjs class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV>
<DIV class=show onClick="id=showjs.innerHTML=ReadAllTest('C:\\JsTest\\CreateText.txt')">
  <SPAN class=ie>JScript</SPAN> <SPAN class=method>ReadAll</SPAN> ¸Þ¼­µå ¿¹Á¦</DIV>
°á°ú Ç¥½Ãâ
VBScript ReadAll ¸Þ¼­µå ¿¹Á¦
<SCRIPT language=VBScript>
Function ReadAllTestvb(filePath)
  Const ForReading=1,ForWriting=2,ForAppending=8
  Dim fso,fileObj,str
  Set fso=CreateObject("Scripting.FileSystemObject")
  If fso.FileExists(filePath) Then
    fso.DeleteFile(filePath)
  End If

  Set fileObj=fso.OpenTextFile(filePath,ForWriting,True)
  fileObj.WriteLine "¿¹Á¦¸¦ À§ÇÑ ÆÄÀÏÀÌ´Ù."
  fileObj.WriteLine "1234567890987654321"
  fileObj.WriteLine "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  fileObj.Close
  str=str&"¿¹Á¦¸¦ À§ÇÑ  "&filePath&" ÆÄÀÏÀ» »ý¼ºÇÏ¿´´Ù.<BR><BR>"

  Set fileObj=fso.OpenTextFile(filePath,ForReading)
  str=str&"fileObj.Read(10)="&fileObj.Read(10)&"<BR>"
  str=str&"fileObj.ReadLine="&fileObj.ReadLine&"<BR>"
  str=str&"fileObj.ReadAll="&fileObj.ReadAll()&"<BR><BR>"

  Set fileObj=fso.OpenTextFile(filePath,ForReading)
  str=str&"fileObj.ReadAll="&fileObj.ReadAll()
  ReadAllTestvb=str
End Function
</SCRIPT>

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