1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

questions about variables, and the FSO

Discussion in 'C#' started by grobar, Jan 22, 2007.

  1. #1
    Three questions...

    1) I read that a variable can only be 255 char, is this true, or is this only true of the variable NAME?

    2) Is it best-practice to set every declared variable to "nothing" immediately after it is no longer needed?

    3) I am using FSO to "publish" updated content to static file. my code goes like this:

    a - delete current file
    b - write new file

    Will the millisecond (possibly more) cause noticeable problems if someone tries to call that file between the time i delete it and the time the new version is written?
    SEMrush
    If so, is there a better way?
     
    grobar, Jan 22, 2007 IP
    SEMrush
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,607
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    1. It is probably true, you should not have a variable this long anyways.

    2. No, most variables will die after the page is loaded. You do want to close connections that can be persistent though (like FSO, and DB, and COM's etc..). Generally dispose and define as nothing (rs.Close() then Set rs = nothing)

    3. Lock the file prior to changing it.
     
    ccoonen, Jan 22, 2007 IP
  3. grobar

    grobar Well-Known Member

    Messages:
    642
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    140
    #3
    THANKS. about the FSO part - I don't totally follow your "lock before edit" solution. Basically, i completely delete the file, and rewrite it as the same filename. Can you point me to a resource on this, or explain in a little more detail please?

    Should I do this:

    1 - lock existing file
    2 - open it for editing
    3 - delete its contents
    4 - write the new contents
    5 - save the file
    6 - unlock

    ????? Does this keep the original version for http requests while im editing it?
     
    grobar, Jan 22, 2007 IP