1

I am getting the error message in my .net code

System.IO.IOException: The process cannot access the file \\servername\direc_name\20150318060043..log because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at SCANLOG(Int64 PLID, String PLLOGIN, String JOURNALID, String JOURNALNAME, DateTime PUSHDATE, Int64 baop) at clspllog.Clspllog.getISSUEPushliveresponse()

I am not able to know which process or module is using the file. Thus just want to know if there is way to know the process name which is using the same file. i would be able to do then some action for this error. Please guilde me.I have checked the file stream , there is no file stream is open .

code is here

private void getISSUEPushliveresponse()
{

WriteToLog("getISSUEPushliveresponse");
clsDB sdb = new clsDB();
this.writetolog("in GetIssuePushliveresponse but blnplatimer= " + StringType.FromBoolean(this.blnplAtimer), 0);
            try
            {
                if (this.blnplitimer)
                {
                    this.blnplitimer = false;
                    string strsql = "SELECT PL.PL_L_PushLiveID,APS.APS_L_JournalID, JM.JM_T_Acronym,PL.PL_D_ActualDate,PL.PL_T_Pushlivelogin FROM  PushLive PL,ApplicationSchedule APS,JournalMaster JM WHERE PL.PL_D_PushliveResponse IS NULL AND( PL.PL_L_PushliveOverdue<>1 OR PL.PL_L_PushliveOverdue IS NULL)  AND PL.PL_D_PushliveInitiated  IS NOT NULL AND PL.PL_B_AOP=0 AND  JM.JM_L_JournalID=APS.APS_L_JournalID  And PL.PL_L_JournalID=APS.APS_L_JournalID";
                    WriteToNewLog("strsql: " + strsql);
                    SqlDataReader reader = sdb.getRecords(strsql);
                    while (reader.Read())
                    {
                        writetolog("Caling Scanlog");
                        this.SCANLOG(LongType.FromObject(reader["PL_L_PUSHLIVEID"]), StringType.FromObject(reader["PL_T_PUSHLIVELOGIN"]), StringType.FromObject(reader["APS_L_JOURNALID"]), StringType.FromObject(reader["JM_T_ACRONYM"]), DateType.FromObject(reader["PL_D_ACTUALDATE"]), 0L);
                    }
                    reader.Close();
                    writetolog("returning to scan log module");
                    this.blnplitimer = true;
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                this.writetolog("exception in getissuepushlive response" +exception1.ToString(), 0);
                this.blnplitimer = true;
                ProjectData.ClearProjectError();
            }
        }
Hamid Pourjam
  • 20,441
  • 9
  • 58
  • 74
Khushi Sharma
  • 51
  • 1
  • 8
  • which code triggers this error? – Tharif Apr 16 '15 at 07:16
  • Here is thread about this http://stackoverflow.com/questions/860656/using-c-how-does-one-figure-out-what-process-locked-a-file – Kodre Apr 16 '15 at 07:23
  • hi @ Bostjan Kodre, the code mentioned in above url is giving me lots of error messages ,is it in vs 2003 . can i have the code which i can deploy instantly on server. – Khushi Sharma Apr 16 '15 at 08:26

0 Answers0