Exemple #1
0
        ///
        /// Find out what process(es) have a lock on the specified file.
        ///

        public static string WhoIsLockingToString(string path)
        {
            List <Process> pl = WhoIsLocking(path);

            if (pl == null || pl.Count == 0)
            {
                return("");
            }

            string msg = pl.Count.ToString() + " processes have locks on: " + path + "\r\n";

            foreach (Process p in pl)
            {
                msg += "ProcessId: " + p.Id + ", ExeFile: " + p.MainModule.FileName + ", " + SystemUtil.GetProcessOwner(p) + "\r\n";
            }

            return(msg);
        }