public void SendFile(int requestId, string filename) { ModMonoWorker worker = GetWorker(requestId) as ModMonoWorker; if (worker == null) { return; } worker.SendFile(filename); }
public override void SendResponseFromFile(string filename, long offset, long length) { if (offset == 0) { FileInfo info = new FileInfo(filename); if (info.Length == length) { if (requestId == -1) { worker.SendFile(filename); } else { requestBroker.SendFile(requestId, filename); } return; } } FileStream file = null; try { file = File.OpenRead(filename); // We must not call the SendResponseFromFile overload which // takes IntPtr in this case since it will callthe base // implementation of that overload which, in turn, will // close the handle (as it uses FileStream to wrap the // handle we pass). This will cause the handle to be closed // twice (FileStream owns the handle). So we just take a // shortcut to what the base overload does here. SendFromStream(file, offset, length); } finally { if (file != null) { file.Close(); } } }