js 를 이용 하여 txt 파일 을 읽 는 방법
1204 단어 과학 연구 기술
1
2
3
4
5
6
7
8
9
function readFile(filename){ var fso = new ActiveXObject( "Scripting.FileSystemObject" ); var f = fso.OpenTextFile(filename,1); var s = "" ; while (!f.AtEndOfStream) s += f.ReadLine()+ "
" ; f.Close(); return s; } js txt 파일 쓰기:
1
2
3
4
5
6
7
8
function writeFile(filename,filecontent){ var fso, f, s ; fso = new ActiveXObject( "Scripting.FileSystemObject" ); f = fso.OpenTextFile(filename,8, true ); f.WriteLine(filecontent); f.Close(); alert( 'ok' ); }