Temporary Files

Discussion in 'ASP .Net' started by Harsh Vardhan Singh, Mar 3, 2005.

  1. hi,

    i am trying to create a temporary file associated with a particular process.
    For instance, i have a windows application which will create a temp file as
    soon as it this program is executed. Now i want this temp file to be
    destroyed if this application is closed / crashes. Is this possible?

    Please help.
    Thanks in advance,
    Harsh
     
    Harsh Vardhan Singh, Mar 3, 2005
    #1
    1. Advertising

  2. Harsh Vardhan Singh

    richlm Guest

    Does it need to be a physical file on disk?
    If not, maybe you could use MemoryStream?
     
    richlm, Mar 3, 2005
    #2
    1. Advertising

  3. yes it has to be on the physical disk.. i think it wud help if i explain
    what i am trying to do... basically i hv to prevent a file from being
    accessed by two users (on different pcs) simultaneously.. so i want to
    create a temp file as soon as one user accesses that file.. now when someone
    else tries to open it, i first check if the temp file is present or not...

    now the problem is removing the temp file in case the program crashes... coz
    if the file is not removed then no user will be able to access it unless the
    temp file is manually deleted.

    this is why i wanted to know if there can be temp files created and
    destroyed along with a process.

    harsh.

    "richlm" <> wrote in message
    news:%23SJ3%...
    > Does it need to be a physical file on disk?
    > If not, maybe you could use MemoryStream?
    >
     
    Harsh Vardhan Singh, Mar 4, 2005
    #3
  4. Harsh Vardhan Singh

    Flip Guest

    Flip, Mar 4, 2005
    #4
  5. Harsh Vardhan Singh

    Amit Bahree Guest

    If you need to create more than one file, then you can use
    TempFileCollection class found in the System.CodeDom.Compiler namespace.
    On MSDN (installed locally) you can find out more at
    ms-help://MS.VSCC.2003/MS.MSDNQTR.2005JAN.1033/cpref/html/frlrfsystemcodedomcompilertempfilecollectionclasstopic.htm

    HTH,
    Amit.

    "Flip" <[remove_me]> wrote in message
    news:[remove_me]:

    > Does this help?
    > http://www.knowdotnet.com/articles/tempfiles.html
    >
    > Here's a manage C++ example. Not perfect but helps a bit.
    > http://www.codeguru.com/Cpp/Cpp/cpp_managed/nfc/article.php/c9255/
    >
    > I believe I've done this with java before, but unsure how to do it in C#, so
    > I just googled it. I still have to finish reading the article myself
    > (sorry), but I'll do that when I get my coffee (right now :>).
    >
    > HTH.
     
    Amit Bahree, Mar 9, 2005
    #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. Replies:
    5
    Views:
    764
    Juan T. Llibre
    Jan 26, 2007
  2. Replies:
    1
    Views:
    682
    bruce barker
    Feb 22, 2007
  3. Replies:
    7
    Views:
    3,260
    James Kanze
    Feb 12, 2008
  4. AAaron123
    Replies:
    3
    Views:
    588
    AAaron123
    Nov 4, 2008
  5. Tim Golden
    Replies:
    0
    Views:
    692
    Tim Golden
    Apr 19, 2010
Loading...

Share This Page