Click to See Complete Forum and Search --> : Creating a unique text file based on passing a variable


sodkgb
07-28-2005, 03:49 PM
Hi,

I want to pass a variable to my asp script to create a unique text file.

'Create copy of Quiz Name Variable
No_space_quiz_name = quiz_name

'Remove spaces from Var Name
No_space_quiz_name = Replace(No_space_quiz_name, " ", "_")

'Create Unique File Name for Test
New_Quiz_Name = No_space_quiz_name & ".txt"
Set filObject = fsoObject.GetFile(Server.MapPath(New_Quiz_Name))

Above does not work?

This below works but is a pre-defined file
'Set filObject = fsoObject.GetFile(Server.MapPath("test_questions.txt"))

Any ideas?

Thanks,

Kevin

buntine
07-28-2005, 09:19 PM
The GetFile function will not create a file. You need to use the CreateTextFile function.

Regards.

sodkgb
07-30-2005, 05:45 PM
Set tsObject = fsoObject.CreateTextFile(Server.MapPath("'"&New_Quiz_Name&"'"))

The above works, I create a form, pass the name of the file, remove spaces and it creates the file.

One problem, the file created has a single quote on either side and it will not work without the single quote?

I get this: 'Kevin_Quiz.txt'

I want this: Kevin_Quiz.txt

HELP! please!

buntine
07-30-2005, 09:28 PM
I'm not sure I follow. Just remove them.

Set tsObject = fsoObject.CreateTextFile(Server.MapPath(New_Quiz_Name))

Regards.

sodkgb
07-31-2005, 09:22 AM
That worked, thank you very much.

All the best,

Kevin

buntine
07-31-2005, 09:53 AM
No worries. ;)