Scripting Runtime Library(TextStream)

TextStream 파일 전체를 읽고 결과로 나오는 문자열을 반환한다.

Script[sVal=]TextStream.ReadAll()
인수/파라메터
object
필수적인 요소이며, 항상 TextStream 개체의 이름이다.
파라메터
파라메터는 없다.
반환값

반환값 sValTextStream 파일 전체를 읽고 결과로 나오는 문자열을 반환한다.

설명

용량이 큰 파일에서 ReadAll 메서드를 사용하면 메모리 리소스를 낭비하게 된다.
한 줄씩 파일 읽기와 같은 다른 기술을 사용하는 것이 좋다.


method
ReadAll 메서드
ReadAll</b> 메서드이전페이지로페이지 맨위로페이지 맨아래로

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>

method
ReadAll 메서드
견본
이전페이지로페이지 맨위로
최종 수정:
07/12/2025 06:25:27
KoXo Homepage
All right reserved
비정상적인 방식으로 프레임없이 페이지에 접속하면 자주 오류가 발생됩니다.
오류가 나면 정상적 접속으로 시도해 보세요.
http://koxo.com/lang/js/method/ReadAll.html