# How to open a file for write

**URL:** https://www.finalbuilder.com/forums/t/how-to-open-a-file-for-write/115
**Category:** Discussion
**Created:** [June 20, 2006, 11:12am UTC](https://www.finalbuilder.com/forums/t/how-to-open-a-file-for-write/115 "2006-06-20T11:12:54Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [June 20, 2006, 11:12am UTC](https://www.finalbuilder.com/forums/t/how-to-open-a-file-for-write/115/1 "2006-06-20T11:12:54Z")

</div>

Hello,  
I am trying to create a file and add content to it dynamically but no luck.  
I can open a file for read using:  
  
ForReading = 1;  
fs = new ActiveXObject(“Scripting.FileSystemObject”);  
a = fs.OpenTextFile(SUBMISSIONFILE, ForReading);  
  
When I try to use the same with a different value (tried 2 & 0) it doesn’t work.  
  
Thanks for your help

---

<div class="post-metadata">

### Author: ![angus](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@angus](https://www.finalbuilder.com/forums/u/angus)
#### Post date: [June 21, 2006, 1:38am UTC](https://www.finalbuilder.com/forums/t/how-to-open-a-file-for-write/115/2 "2006-06-21T01:38:28Z")

</div>

I think that if the file doesn’t exist you need to pass in “true” for the optional “create” parameter, ie  
  
var ForWriting = 2;  
a = fs.OpenTextFile(SUBMISSIONFILE, ForWriting, true);  
  
Hth.

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [June 21, 2006, 2:43am UTC](https://www.finalbuilder.com/forums/t/how-to-open-a-file-for-write/115/3 "2006-06-21T02:43:24Z")

</div>

It worked. Thanks for your help.   
Where can I find help about the functions supported? I tried to use 2 but didn’t know I should have another parameter. I even created the file manually but I guess I needed a third parameter.

---

<div class="post-metadata">

### Author: ![angus](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@angus](https://www.finalbuilder.com/forums/u/angus)
#### Post date: [June 22, 2006, 1:07am UTC](https://www.finalbuilder.com/forums/t/how-to-open-a-file-for-write/115/4 "2006-06-22T01:07:13Z")

</div>

MSDN has some reference pages for the FileSystemObject, for instance:  
  
[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/32a1c6c4-255b-4281-8bd8-213096ea1fe0.asp](http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/32a1c6c4-255b-4281-8bd8-213096ea1fe0.asp)  
  
To find the answer above I just googled ‘FileSystemObject OpenTextFile’. The first google link was a great summary by a third party website.  
  
(Go google!)
