public void SendMessage(string recipient, string messageHead, string messageBody) { List <string> fileNameVec = FileSystem.ListFilesInDirectory(Globals.IpcPath); bool found = true; int fileCount = 0; while (found) { found = false; foreach (string fileNameCurrent in fileNameVec) { if (fileNameCurrent == recipient + fileCount.ToString()) { found = true; ++fileCount; break; } } } string pathOld = Globals.IpcPath + "\\s" + selfName + IPC.SentCount.ToString(); string pathNew = Globals.IpcPath + "\\" + recipient + fileCount.ToString(); FileSystem.WriteStringToFile(pathOld, messageHead + "!" + messageBody); FileSystem.RenameFile(pathOld, pathNew); ++IPC.SentCount; Globals.WriteLine("message sent: " + recipient + " " + messageHead + " " + messageBody); }