...

View Full Version : Read and Write Files



Sysop_Neo
09-23-2005, 08:50 AM
Hi all,

one question ... Exist in Javascript the option to Write and read files ?

something like:


if user enter here then write 1 on example.txt

and/or:


if user enter here then read example.txt

?

Bye,

Neo

martin_narg
09-23-2005, 09:09 AM
You can use the FileSystemObject to read/write files in Internet Explorer and there is a Mozilla alternative, but there will be nasty security warnings popping up at best, and this process will be totally blocked at worst by the user's browser.

If the application is to be run localy on a windows machine, you can use an .hta file or somesuch. If possible - try to do this server-side.

Sysop_Neo
09-24-2005, 02:24 PM
hi all,

hmmm first of all thanks for the feedback (y)))))

but i have a problem ... im new in javascript programmation so i need to ask you one more thing ... could you make a sample of a FileSystemObject for i learn how that works please? Thanks .... Don't need many options something for i test and see how that works ... and also if you want your SiteLogo for i put on my afiliates sites (I like ask for help but i like also put a "linkback" for who help me)

Bye,
Neo

PS: or as alternative if you know how we create a .hta when we are running with a IIS server and Win 2003 as OS.

martin_narg
09-24-2005, 04:34 PM
Use ASP/VBScript:

Writing a file:
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("c:\testfile.txt", True)
MyFile.WriteLine("This is a test.")
MyFile.Close
Reading a file:
Const ForReading = 1
Dim fso, f, strContents
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\testfile.txt", ForReading)
strContents = f.ReadAll
FileSystemObject Reference (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/jsmthopentextfile.asp)

But you'd be better off using a database to store data in.

Hope this helps.

m_n

Sysop_Neo
09-24-2005, 07:35 PM
thanks, i think so ...


bye (b)

Neo



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum