获取使用相同文件的进程名称

时间:2015-04-16 07:14:09

标签: c# file-io

我在.net代码中收到错误消息

  

System.IO.IOException:进程无法访问该文件   \\ servername \ direc_name \ 20150318060043..log,因为它正由另一个进程使用。在System.IO .__ Error.WinIOError(Int32   System.IO.FileStream..ctor中的errorCode,String str)(字符串路径,   FileMode模式,FileAccess访问,FileShare共享,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()

我无法知道哪个进程或模块正在使用该文件。因此,只想知道是否有办法知道使用相同文件的进程名称。我可以为此错误做一些操作。 请guilde me.I已检查文件流,没有文件流打开。

代码在这里

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();
            }
        }

0 个答案:

没有答案