What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Help for a Script Beginner - Open File in Scripts

Help for a Script Beginner - Open File in Scripts
Author: Message:
blueeyez
New Member
*


Posts: 2
Joined: Jan 2008
O.P. Help for a Script Beginner - Open File in Scripts
hay guys...is there any method to open a file in a messenger live script to read/write from it?

thanks for ur help in advance
blueeyez
01-08-2008 11:15 AM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: Help for a Script Beginner - Open File in Scripts
You can use the FileSystem ActiveXObject to open a text file, read from it and write to it.
code:
var Path = MsgPlus.ScriptFilesPath + "\\Stuff.txt"; //The path to the file to read / write to.
var IsUnicode = false; //Set this to true if you want to read / write in Unicode.

//Read the file
var FSO = new ActiveXObject("Scripting.FileSystemObject");
var File = FSO.GetFile(Path);
var TextStream = FSO.OpenAsTextStream(1, IsUnicode ? -1 : 0);
var Contents = TextStream.ReadAll();
TextStream.Close();
//Do something useful with Contents...

//Write the file
var Contents = "This is the new content of the file!";
var FSO = new ActiveXObject("Scripting.FileSystemObject");
var File = FSO.GetFile(Path);
var TextStream = FSO.OpenAsTextStream(2, IsUnicode ? -1 : 0);
TextStream.Write(Contents);
TextStream.Close();
Or, if you want to get really advanced, you could use the Windows API for this... but I doubt that as a beginner, you'd want to get on to something that complicated. :P

References:
FileSystemObject
TextStream object
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
01-08-2008 05:37 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On