Best approach - writing text file

Discussion in 'ASP General' started by Rob Meade, Dec 13, 2003.

  1. Rob Meade

    Rob Meade Guest

    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
     
    Rob Meade, Dec 13, 2003
    #1
    1. Advertising

  2. Rob Meade wrote:

    > 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")


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Dec 13, 2003
    #2
    1. Advertising

  3. Rob Meade

    Rob Meade Guest

    "Martin Honnen" wrote ...

    > 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
     
    Rob Meade, Dec 13, 2003
    #3
  4. Rob Meade wrote:

    > "Martin Honnen" wrote ...
    >
    >
    >>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?


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

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Dec 14, 2003
    #4
  5. Rob Meade

    Rob Meade Guest

    "Martin Honnen" wrote ...

    > 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
     
    Rob Meade, Dec 14, 2003
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. HNguyen
    Replies:
    4
    Views:
    2,440
    HNguyen
    Dec 21, 2004
  2. Replies:
    1
    Views:
    351
  3. Ben Finney

    approach to writing functions

    Ben Finney, Feb 10, 2004, in forum: Python
    Replies:
    17
    Views:
    498
    Joe Mason
    Feb 11, 2004
  4. John Heitmuller.
    Replies:
    1
    Views:
    231
    Evertjan.
    May 28, 2009
  5. Himanshu Garg
    Replies:
    1
    Views:
    95
    Chris Angelico
    Nov 15, 2013
Loading...

Share This Page