示例#1
0
        public bool Download(string fileName, string destination)
        {
            if (!_parent.IsConnected())
            {
                return(false);
            }
            if (fileName == "" || fileName == null)
            {
                _parent.Log("JRiver: Download [128] Null/Blank Filename: Ending.  Destination:" + destination);
                return(false);
            }

            try
            {
                using (var client = new WebClient())
                {
                    var credentials = _parent.GetCredentials();
                    if (credentials != null)
                    {
                        client.Credentials = credentials;
                    }
                    client.Headers.Add("Token", _parent.JRiverAuthToken);
                    _parent.Log("JRRiver Download: Filename:" + fileName + @", destination:" + destination);
                    client.DownloadFile(_parent.GetDownloadPath(fileName), destination);
                }
                _parent.Log("DOWNLOAD : " + fileName);
                return(true);
            }
            catch (WebException e)
            {
                _parent.Log("ERROR - DOWNLOAD : " + _parent.GetDownloadPath(fileName) + " " + e.Message);
            }
            return(false);
        }