[Modify] Use it

This commit is contained in:
sta 2016-11-17 16:41:07 +09:00
parent bc4b4a9d8e
commit f5ab00bf4e

View File

@ -2696,15 +2696,19 @@ namespace WebSocketSharp
/// </exception> /// </exception>
public void Send (FileInfo file) public void Send (FileInfo file)
{ {
if (file == null)
throw new ArgumentNullException ("file");
if (_readyState != WebSocketState.Open) { if (_readyState != WebSocketState.Open) {
var msg = "The current state of the connection is not Open."; var msg = "The current state of the connection is not Open.";
throw new InvalidOperationException (msg); throw new InvalidOperationException (msg);
} }
send (Opcode.Binary, file.OpenRead ()); if (file == null)
throw new ArgumentNullException ("file");
FileStream stream;
if (!file.TryOpenRead (out stream))
throw new ArgumentException ("Cannot be opened to read.", "file");
send (Opcode.Binary, stream);
} }
/// <summary> /// <summary>