Editing a text file on line

Results 1 to 3 of 3

Thread: Editing a text file on line

  1. #1
    Join Date
    Dec 1969
    Posts
    1,016

    Default Editing a text file on line

    I want to be able to have a text file as part of a main asp file, but i want to be able to edit it on-line with another. Has any one got any suggestions please. I am loosing my hair over this.

  2. #2
    Kenneth D. Searles Guest

    Default RE: Editing a text file on line (ANSWER)

    Here is the code that I used to do the same thing.<BR><BR>The first thing I did was included the text file to my display page with a server side include. Then, I had a page that opened the text file into a textbox, like so:<BR><BR>&#060;form method="POST" action="Update.asp" id="form1" name="form1"&#062;<BR>&#060;p align="Center"&#062;&#060;textarea rows="25" name="txtText" id="txtText" cols="100" wrap="soft"&#062;<BR>&#060;%<BR> Set InStream = Server.CreateObject("Scripting.FileSystemObject")< BR> Set InFile = InStream.OpenTextFile("&#060;File Path&#062;&#060;File Name&#062;", 1, True)<BR><BR> Text = InFile.ReadAll<BR> Response.Write(Text)<BR> InFile.Close<BR>%&#062;<BR>&#060;/textarea&#062;&#060;/p&#062;<BR>&#060;p align="Center"&#062;&#060;input type="submit" value="Make the Changes!" name="B1"&#062;&#060;/p&#062;<BR>&#060;/form&#062;<BR><BR>Then you need a page that will process the changes and update the text file, like so:<BR><BR> Set OutStream = Server.CreateObject("Scripting.FileSystemObject")< BR> Set OutFile = OutStream.OpenTextFile("&#060;File Path&#062;&#060;File Name&#062;", 2, True)<BR> <BR> OutFile.Write Request.Form("txtText")<BR> OutFile.Close<BR> <BR> Response.Redirect "default.asp"<BR><BR>And voila, it&#039s done. If you have any questions, feel free to ask; Kenneth@DeltaSig.com.

  3. #3
    Manpreet Guest

    Default RE: EDITING A TXT FILE ONLINE

    ur question is not very clear, but still from what i understand u have a txt file which u want to edit in the browser.<BR><BR>if that&#039s right u can first create a FileSystemObject and then call the OpenTextFile method over it specifiying the file u want to edit. once u do that read the entire file into a string variable(say "txt_file") using the "read" method. then just make a textarea - <BR>"&#060;textarea&#062;" & txt_file & "&#060;/textarea&#062;"<BR>and the file will open in the textarea.<BR>afetr u are dun with the editing have a submit buttin which would do exactly the reverse and store the textarea contents in the file (overwrite it).<BR><BR><BR><BR><BR><BR><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
  •