コード例 #1
0
        public string Download(string savePath)
        {
            try
            {
                if (string.IsNullOrEmpty(savePath))
                {
                    throw new ArgumentException("Invalid argument.");
                }

                string fileName = GetFilename(savePath, _youTube.Title);

                if (!SaveFileToDisk(fileName, _youTube.GetBytes()))
                {
                    throw new IOException("Could not save file on disk.");
                }

                Downloaded?.Invoke(this, new EventArgs());

                return(fileName);
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
                return(string.Empty);
            }
        }