File i/o help

Results 1 to 2 of 2

Thread: File i/o help

  1. #1
    Join Date
    Dec 1969
    Posts
    10

    Default File i/o help

    Ok this may seem simple but I was hoping someone could post a simple explaination of File i/o on this thread. Specifically I would like to know how to create a text file and write a string to it. I would also like to know how to <BR><BR>* overwrite the file<BR>* append<BR>* delete the file completly<BR><BR>I know how to read the file just don&#039t know the syntax for the other stuff. thanks

  2. #2
    Jason Buck Guest

    Default RE: File i/o help

    The answers to most of your question can be found here:<BR>http://msdn.microsoft.com/scripting/vbscript/doc/vbsfsoTOC.htm<BR><BR>&#039Create a files<BR> Dim fso, MyFile<BR> Set fso = CreateObject("Scripting.FileSystemObject")<BR> Set MyFile = fso.CreateTextFile("c: estfile.txt", True)<BR> MyFile.WriteLine("This is a test.")<BR> MyFile.Close<BR><BR>&#039Write to a file<BR><BR> Set FileObject = Server.CreateObject("Scripting.FileSystemObject")< BR><BR> TestFile = Server.MapPath ("/telogs") & " elogin.txt"<BR> Set OutStream= FileObject.OpenTextFile (TestFile, 8, TRUE)<BR><BR> ipaddr=Request.ServerVariables("REMOTE_ADDR") & " : "<BR> <BR> OutStream.Write ipaddr & "tried to login using UserName: &#060;b&#062;" & request.form("UserName") & "&#060;/b&#062; or Password: &#060;b&#062;" & request.form("password") & "&#060;/b&#062;. One of these was incorrect." & " " & Now()<BR> OutStream.WriteLine textstr & "<BR>"<BR> Set OutStream = Nothing<BR><BR>&#039Delete a file<BR><BR> Dim fso<BR> Set fso = CreateObject("Scripting.FileSystemObject")<BR> fso.DeleteFile(filespec)<BR><BR><BR>Please check out the scripting link above.<BR>I hope this helps you, if not feel free to contact me.<BR><BR>Respectfully,<BR><BR>Jason<BR>webmaster @wnj.com<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •