file accessing problem---urgent

Discussion in 'Software' started by mpnthi, Oct 2, 2008.

  1. mpnthi

    mpnthi

    Joined:
    Oct 1, 2008
    Messages:
    1
    hi


    public void addLogEntry(string log_type ,string logText)
    {
    if ((File.Exists(sLogPath))== false)
    {
    swFileWriter = File.CreateText(sLogPath);
    swFileWriter.Close();
    }
    FileInfo f=new FileInfo(sLogPath);
    swFileWriter=f.AppendText();
    swFileWriter.WriteLine(" ");
    swFileWriter.WriteLine(DateTime.Now.ToString() + " " + log_type + " " + logText);
    swFileWriter.Close();
    }
    this is my code.

    but i am getting error at this line "swFileWriter=f.AppendText();"

    and the error is "process cannot access the file because it is being used by another process".i understood the problem why the error coming
    because two processes are wish to write to single log file at a time...
    Multi-users perform writing the same file at the same time.
    can we lock the file ?or is there any suggestions on this...
    i am using c#,asp.net,vs2005
    if anybody can help..please..its very urgent

    Thanks in Advance
     
    mpnthi, Oct 2, 2008
    #1
    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. ijones@iTOGLIinterfree.it

    MovieFactory 5: is it possible to create a VOB file? URGENT!!

    ijones@iTOGLIinterfree.it, Jul 9, 2006, in forum: DVD Video
    Replies:
    0
    Views:
    510
    ijones@iTOGLIinterfree.it
    Jul 9, 2006
  2. stratocasted

    URGENT HELP required for olympus orf raw file

    stratocasted, Nov 10, 2006, in forum: Digital Photography
    Replies:
    11
    Views:
    950
    grruffbowwow@yahoo.com
    Nov 10, 2006
  3. Security Advisory

    !!URGENT!! Tor Vulnerability Discovered !!URGENT!!

    Security Advisory, Aug 6, 2007, in forum: Computer Security
    Replies:
    1
    Views:
    991
    http://tinyurl.com/23k3dt@$NIFF-deeply.ahh
    Aug 11, 2007
  4. pooja
    Replies:
    0
    Views:
    1,214
    pooja
    Mar 3, 2009
  5. Griffin
    Replies:
    0
    Views:
    657
    Griffin
    Aug 27, 2010
Loading...

Share This Page