public FtpMediaStream(IngestMedia media, bool forWrite) { _media = media; if (media == null || media.Directory == null) { throw new ApplicationException(); } Uri uri = new Uri(media.FullPath); _client = new System.Net.FtpClient.FtpClient(); _client.Credentials = ((IngestDirectory)media.Directory)._getNetworkCredential(); _client.Host = uri.Host; try { _client.Connect(); if (forWrite) { _ftpStream = _client.OpenWrite(uri.LocalPath); } else { _ftpStream = _client.OpenRead(uri.LocalPath); } } catch { _client.Dispose(); throw; } }
public FtpMediaStream(IngestMedia media, bool forWrite) { if (media?.Directory == null) { throw new ApplicationException(); } var uri = new Uri(media.FullPath); _client = new System.Net.FtpClient.FtpClient { Credentials = ((IngestDirectory)media.Directory).GetNetworkCredential(), Host = uri.Host }; try { _client.Connect(); _ftpStream = forWrite ? _client.OpenWrite(uri.LocalPath) : _client.OpenRead(uri.LocalPath); } catch { _client.Dispose(); throw; } }
protected override void Dispose(bool disposing) { if (disposing) { _ftpStream.Dispose(); _client.Dispose(); } base.Dispose(disposing); }
public FtpMediaStream(IngestMedia media) { _media = media; if (media == null || media.Directory == null) throw new ApplicationException(); Uri uri = new Uri(media.FullPath); _client = new System.Net.FtpClient.FtpClient(); _client.Credentials = media.Directory.NetworkCredential; _client.Host = uri.Host; try { _client.Connect(); _ftpStream = _client.OpenRead(uri.LocalPath); } catch { _client.Dispose(); } }