uAL.TorrentAPI.GetDownloadDir C# (CSharp) Method

GetDownloadDir() public method

public GetDownloadDir ( ) : string
return string
        public string GetDownloadDir()
        {
            string dir = "NA";

            HttpWebRequest getProperties = (HttpWebRequest)(HttpWebRequest.Create(host + "?action=getsettings&token=" + token));
            getProperties.Credentials = credentials;
            getProperties.Headers.Add("Cookie", cookie);
            HttpWebResponse response = (HttpWebResponse)getProperties.GetResponse();
            StreamReader sr = new StreamReader(response.GetResponseStream());
            dir = (string)sr.ReadToEnd();
            response.Close();

            JsonObject res = (JsonObject)JsonConvert.Import(dir);
            JsonArray settings = (JsonArray)res["settings"];
            foreach (JsonArray se in settings)
            {
                string _prop = (string)se[0];
                if(_prop == "dir_autoload")
                    dir = (string)se[2];
            }

            return dir;
        }

Usage Example

Example #1
0
 private void Connect()
 {
     if (Properties.Settings.Default.validConnectionSettings)
     {
         try
         {
             _connecting = true;
             TorrentAPI ta = new TorrentAPI(Properties.Settings.Default.hostname, Properties.Settings.Default.username, Properties.Settings.Default.password);
             Properties.Settings.Default.torrentDir = ta.GetDownloadDir();
             _connecting = false;
             _connected = true;
         }
         catch (Exception ex)
         {
             _connecting = false;
             _connected = false;
         }
     }
 }
All Usage Examples Of uAL.TorrentAPI::GetDownloadDir