Best approach - writing text file

R

Rob Meade

Hi all,

Ok - minor fly in my ointment...

I have an application which was successfully writing data from submitted
forms to a text file in a directory - in this case:

/data/findata.txt

This was fine because the forms lived at the root level with this directory.

Since then I have added enabled the forms to be used on subdirectories :

/subdirectory/myform.asp

I've used the same code for server.mapparth("data") etc - but instead of
locating the directory at the root of the server called "data" it looks to
the current directory- doesn't find it and creates another! eek!

What I need is a way to say "right, it doesnt matter what level you are at
at the moment, always look at the root level /data directory"...

This has to be fairly dynamic - on the development server here its got a
different file structure than on the live server (ie, it lives another level
down again on the physical drive)...

Anyone got a good idea on how to look back up?

I do have one way to test which level they are at - but I feel that its a
bit 'weak' - I have an ID that tells me if they are working on the upper or
lower levels (ie, anything other than 1 is a lower level) - whilst I realise
I could use this in the test I'm not sure if its going to be 100% fool proof
to base this criteria on this ID.

Therefore I was hoping for a better way using the server.mappath etc...

Thanks in advance for any help.

Regards

Rob
 
M

Martin Honnen

Rob said:
Hi all,

Ok - minor fly in my ointment...

I have an application which was successfully writing data from submitted
forms to a text file in a directory - in this case:

/data/findata.txt

This was fine because the forms lived at the root level with this directory.

Since then I have added enabled the forms to be used on subdirectories :

/subdirectory/myform.asp

I've used the same code for server.mapparth("data") etc - but instead of
locating the directory at the root of the server called "data" it looks to
the current directory- doesn't find it and creates another! eek!

What I need is a way to say "right, it doesnt matter what level you are at
at the moment, always look at the root level /data directory"...

So you want
Server.MapPath("/data")
 
R

Rob Meade

...
So you want
Server.MapPath("/data")

Hi Martin,

Thanks for your reply - the / looks 'anywhere' then does it?

Incidently - if I had more than one data directory - how would it know which
to return as correct? Or would it just return the last one it finds?

Cheers

Rob
 
M

Martin Honnen

Rob said:
...




Hi Martin,

Thanks for your reply - the / looks 'anywhere' then does it?

Incidently - if I had more than one data directory - how would it know which
to return as correct? Or would it just return the last one it finds?

No, / is the root of the virtual server directory structure and
Server.MapPath("/data")
looks for a data directly under the root.
 
R

Rob Meade

...
No, / is the root of the virtual server directory structure and
Server.MapPath("/data")
looks for a data directly under the root.

Hi Martin,

Many thanks for your reply - I will give that a go...

Thanks again,

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top