Click to See Complete Forum and Search --> : [RESOLVED] CreateTextFile Not Creating File Where Needed


nbcrockett
08-05-2009, 11:12 AM
I've written a script that exports records from a database and creates an XML file from those records. The script works fine if I'm creating the file in that websites directory, but if I want to create it else where on that server it won't write. Can anyone tell me what I'm doing wrong?

Works: Site 1 writing to folder in Site 1's directory.

Set strCreate = fso.CreateTextFile(server.mappath("/Exported Files/File.xml"), true)


Doesn't Work: Site 1 writing to folder in Site 2's directory.

Set strCreate = fso.CreateTextFile(server.mappath("D:Websites/Site2/Exported Files/File.xml"), true)

Kuriyama
08-05-2009, 12:14 PM
I've written a script that exports records from a database and creates an XML file from those records. The script works fine if I'm creating the file in that websites directory, but if I want to create it else where on that server it won't write. Can anyone tell me what I'm doing wrong?

Works: Site 1 writing to folder in Site 1's directory.

Set strCreate = fso.CreateTextFile(server.mappath("/Exported Files/File.xml"), true)


Doesn't Work: Site 1 writing to folder in Site 2's directory.

Set strCreate = fso.CreateTextFile(server.mappath("D:Websites/Site2/Exported Files/File.xml"), true)



Why do you need server.mappath if you already have the file path? Try this. . .

Set strCreate = fso.CreateTextFile("D:Websites/Site2/Exported Files/File.xml", true)

nbcrockett
08-05-2009, 01:20 PM
Thanks for the help. The server.mappath thing was copied over from something else and it didn't even cross my mind to remove it. In the words of Carlos Mancia "dee dee dee"