objFSO.CreateTextFile("textfile.txt") 
Author Message
 objFSO.CreateTextFile("textfile.txt")

This is probably a simple question, but I've yet to find the answer.

I have a script that pulls a recordset and then writes the recordset to a
textfile.  My problem, is in specifying where to write the text file.  I
thought this would be simple.  Not so.  With the following code

Set infoTextStream = objFSO.CreateTextFile("txtFile.txt", True)

the text file is written to c:\winnt\system32

But if I try
("/rootdirectory/someotherdirectory/someotherdirectory/txtFile.txt")

It advises that the path doesn't exist.  How do I specify the correct path?

Jay



Sat, 24 May 2003 03:00:00 GMT  
 objFSO.CreateTextFile("textfile.txt")
Set infoTextStream = _
  objFSO.CreateTextFile(Server.MapPath("txtFile.txt"), True)

writes it to the same folder as the calling ASP page...

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--


Quote:
> This is probably a simple question, but I've yet to find the answer.

> I have a script that pulls a recordset and then writes the recordset to a
> textfile.  My problem, is in specifying where to write the text file.  I
> thought this would be simple.  Not so.  With the following code

> Set infoTextStream = objFSO.CreateTextFile("txtFile.txt", True)

> the text file is written to c:\winnt\system32

> But if I try
> ("/rootdirectory/someotherdirectory/someotherdirectory/txtFile.txt")

> It advises that the path doesn't exist.  How do I specify the correct
path?

> Jay



Sat, 24 May 2003 03:00:00 GMT  
 objFSO.CreateTextFile("textfile.txt")
Hi

Try
Set fso = CreateObject("Scripting.FileSystemObject")
set infoTextStream =
fso.OpenTextFile("c:\windows\desktop\txtfile.txt",2,True)

--
Tom
-------------------------------------
http://engines2go.com - Fast access to all the major search engines.
No Ads, Pictures or Banners.


Quote:
> This is probably a simple question, but I've yet to find the answer.

> I have a script that pulls a recordset and then writes the recordset to a
> textfile.  My problem, is in specifying where to write the text file.  I
> thought this would be simple.  Not so.  With the following code

> Set infoTextStream = objFSO.CreateTextFile("txtFile.txt", True)

> the text file is written to c:\winnt\system32

> But if I try
> ("/rootdirectory/someotherdirectory/someotherdirectory/txtFile.txt")

> It advises that the path doesn't exist.  How do I specify the correct
path?

> Jay



Sun, 25 May 2003 12:51:37 GMT  
 objFSO.CreateTextFile("textfile.txt")
How about wscript.scriptfullname and wscript.scriptname which provide
path+filename and filename so you can easily get the
path of the script.

Werner



Sun, 25 May 2003 03:00:00 GMT  
 objFSO.CreateTextFile("textfile.txt")
Thanks Michael!  That's exactly what I was looking for!

Jay


Quote:
> Set infoTextStream = _
>   objFSO.CreateTextFile(Server.MapPath("txtFile.txt"), True)

> writes it to the same folder as the calling ASP page...

> --
> Michael Harris
> Microsoft.MVP.Scripting
> --

> Please do not email questions - post them to the newsgroup instead.
> --



> > This is probably a simple question, but I've yet to find the answer.

> > I have a script that pulls a recordset and then writes the recordset to
a
> > textfile.  My problem, is in specifying where to write the text file.  I
> > thought this would be simple.  Not so.  With the following code

> > Set infoTextStream = objFSO.CreateTextFile("txtFile.txt", True)

> > the text file is written to c:\winnt\system32

> > But if I try
> > ("/rootdirectory/someotherdirectory/someotherdirectory/txtFile.txt")

> > It advises that the path doesn't exist.  How do I specify the correct
> path?

> > Jay



Sun, 25 May 2003 03:00:00 GMT  
 objFSO.CreateTextFile("textfile.txt")
Thanks to everyone who replied.  You've given me many ways to make this
work!

Jay


Quote:
> This is probably a simple question, but I've yet to find the answer.

> I have a script that pulls a recordset and then writes the recordset to a
> textfile.  My problem, is in specifying where to write the text file.  I
> thought this would be simple.  Not so.  With the following code

> Set infoTextStream = objFSO.CreateTextFile("txtFile.txt", True)

> the text file is written to c:\winnt\system32

> But if I try
> ("/rootdirectory/someotherdirectory/someotherdirectory/txtFile.txt")

> It advises that the path doesn't exist.  How do I specify the correct
path?

> Jay



Sun, 25 May 2003 03:00:00 GMT  
 objFSO.CreateTextFile("textfile.txt")
Michael, your are undoubtably a genius and an asset to this newsgroup. In
the space of half an hour you have helped me out twice.

Thanks on behalf of the entire group.

Andrew Jones


Quote:
> Set infoTextStream = _
>   objFSO.CreateTextFile(Server.MapPath("txtFile.txt"), True)

> writes it to the same folder as the calling ASP page...

> --
> Michael Harris
> Microsoft.MVP.Scripting
> --

> Please do not email questions - post them to the newsgroup instead.
> --



Sun, 01 Jun 2003 19:20:13 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. objFSO.createTextFile error

2. txt.Span " ,;:.?!", True, True

3. How: x=shell("C:\MYFILE.TXT")

4. inet execute size "test.txt"

5. Help my win32api.txt is "ERROR"

6. *"*-.,._,.-*"* I"LL TRADE VISUAL C++ FOR VBASIC *"*-.,_,.-*"*

7. replacing "to" to "2" internet txt msging

8. Disabling "BACK"/"FORWARD" buttons

9. CreateObject("Excel","//server"), MsgBox output

10. Problem With "window.showmodaldialog("")"

11. Disabling "BACK"/"FORWARD" buttons

12. GetObject("","InternetExplorer.Application") fails in Excel VBA

 

 
Powered by phpBB® Forum Software