Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

How do I read from a text file using JavaScript in an ASPX page?

Avatar of exx1976
exx1976Flag for United States of America asked on
JavaJavaScriptJScript
32 Comments1 Solution2225 ViewsLast Modified:
I am trying to read the contents of a text file (it could be an XML file if need be, any type of file) into the JS on the web page so that I can compare user input against a list of allowed inputs.  Can anyone throw up some code as to how to do this?  I'm not really too strong on JS, I'm more of a VBS kinda guy, but this whole site is already written in JS.

Here's what I've written so far, please feel free to hack it up/make it work by any means possible.

Thanks!
function check(Name){
	var data = "";
	var fileObj = new ActiveXObject("Scripting.FileSystemObject");
	if (fileObj.FileExists("C:\Inetpub\wwwroot\Citrix\XenApp\auth\clientscripts\names.txt")) {
		var f = fileObj.GetFile("C:\Inetpub\wwwroot\Citrix\XenApp\auth\clientscripts\name.txt",1);
		var ts = f.OpenAsTextStream(1,0);
		while (!f.AtEndOfStream) {
			data = ts.ReadLine();
			if (data == Name) {
				txtStream.Close();
				return true;
			}
		}
		txtStream.Close();
	}
	return false;
}
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick BarryFlag of Australia imageJava Developer
Commented:
This problem has been solved!
Unlock 1 Answer and 32 Comments.
See Answers