473,480 Members | 1,839 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

problem with 'Scripting.FileSystemObject'

8 New Member
Hi ,
I tried to write a Line at the end of my file Test.txt.

[HTML]function AddNewL(){
var Object = new ActiveXObject('Scripting.FileSystemObject'); var LirTxt2 = Object.GetFile("F:\Test.txt");
var ForWriting=2; //to be able to write
var doc2 = LirTxt.OpenAsTextStream(ForWriting,true); doc2.WriteLine("byebye); //
doc2.Close(); //close the file
} [/HTML]


But I can only manage to overwrite and i loose my first lines.
If someone has a good idea,
many thanks
Jan 18 '07 #1
7 3403
iam_clint
1,208 Recognized Expert Top Contributor
You need to read the txt file first set the previous text to a variable then write it all back as one other than that I don't use FSO in my javascripts security problems with it.
Jan 18 '07 #2
Bogey
8 New Member
You need to read the txt file first set the previous text to a variable then write it all back as one other than that I don't use FSO in my javascripts security problems with it.
Thank iam_clint for your advice
Jan 18 '07 #3
Bogey
8 New Member
I am not sure to understand correctly,
[HTML]
function AddNewL(){
var Object = new ActiveXObject('Scripting.FileSystemObject'); var LirTxt2 = Object.GetFile("F:\Test.txt");
var ForReading = 1;
var myText = LirTxt2.OpenTextFile("F:\Test.txt", ForReading);
myText = ts.ReadLine();
var ForWriting=2; //to be able to write
var doc2 = fso.OpenAsTextStream(myText,true); doc2.WriteLine("byebye); //
doc2.Close(); //close the file
}[/HTML]

It did not work.
Please can you explain it again.thank
Jan 18 '07 #4
iam_clint
1,208 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1. doc2.WriteLine("byebye); //
  2.  
  3. Needs to be
  4.  
  5. doc2.WriteLine("byebye"); //
  6.  
Expand|Select|Wrap|Line Numbers
  1. function AddNewL(){
  2.     var Object = new ActiveXObject('Scripting.FileSystemObject');     var LirTxt2 = Object.GetFile("F:\Test.txt"); 
  3.                 var ForReading = 1;
  4.                  var myText = LirTxt2.OpenTextFile("F:\Test.txt", ForReading);
  5.                  myText = ts.ReadLine();
  6.     var ForWriting=2; //to be able to write
  7. var doc2 = fso.OpenAsTextStream(myText,true);     
  8. doc2.WriteLine(myText+"byebye"); // 
  9.     doc2.Close(); //close the file
  10. }
  11.  
Jan 18 '07 #5
Bogey
8 New Member
Congratulation i_am clint ,
Your solution is great .
You saved my day.thanks
Jan 18 '07 #6
sageman
2 New Member
I think you were using the wrong Const;
ForReading = 1
ForWriting = 2
ForAppending = 8

you wanted an 8 and you were using a 2. try an 8 and your original shorter code should work fine.
Jan 18 '07 #7
Bogey
8 New Member
You are rigth Sageman, Thanks
with 8 it's working
Jan 19 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1850
by: sb | last post by:
I'm trying to come up with a simple script to iterate through a bunch of images in a directory and delete the ones that haven't been viewed in x number of months. I thought "DateLastAccessed"...
2
2801
by: Fedroz | last post by:
Hi! Here is my problem: I'm trying a simple script copied by MSDN for read a text file and put the content on output web page! I use the following code: Const ForReading = 1, ForWriting = 2,...
9
9779
by: Ed | last post by:
Is there any known issue with the use of "Scripting.FileSystemObject"? Here's a snippet of my code to obtain the filesize of a file Set fso = CreateObject("Scripting.FileSystemObject") Set...
2
2291
by: John | last post by:
Can't get this to work. I'm creating a workaround for the absence of aspJPEG on my server. I'm using aspUpload but my server only uses aspThumb. After aspThumb optimizes the original pic the file...
1
5609
by: andrewcw | last post by:
I have used System.Management in the past to extract and walk thru drives & check their type. I can also do it with COM's FileSystemObject. Here I am trying to just use the Management Object...
0
907
by: bobsab | last post by:
Hi all, My application uses ASP and several COM objects. The communication between ASP and the COMs works perfectly, and I have no errors when I call "Server.CreateObject" from ASP. The problem...
7
8813
ADezii
by: ADezii | last post by:
The next series of Tips will involve the Microsoft Scripting Runtime Library (Scrrun.dll). This Library is, in my humble opinion, one of the most useful and practical Libraries ever created. With the...
0
5135
ADezii
by: ADezii | last post by:
This is the 2nd Tip in a series of Tips on the Microsoft Scripting Runtime Library. The 1st Tip related to Drives, while this Tip will concentrate on the Folders (Directories) in your PC and various...
0
5398
ADezii
by: ADezii | last post by:
This is the 3rd in a series of Tips dealing specifically with the Microsoft Scripting Runtime Library. In this Tip, we'll show you how to return specific Properties relating to Files, as well as...
0
4451
ADezii
by: ADezii | last post by:
This is the last in a series of Tips involving the Microsoft Scripting Runtime Library and deals with creating, opening, writing to, reading from, and closing Text Files via this Library. At this...
0
7041
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7043
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7081
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
6921
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5336
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4481
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.