I have to make a program to back up my IDM download list every day, because there is other ones using my computer and they removing my download list.
IDM API only lets me add download to IDM list, so is there any library or other way to back up my IDM download list using C#?
thanks for helping
Thanks to #Setsu found out a solution. there is a key in registry which contains all of the URLs. the key is HKEY_CURRENT_USER\Software\DownloadManager and it contains keys which contains values named Url0 with the URL in it.
As an example HKEY_CURRENT_USER\Software\DownloadManager\85\Url0 contains one of added link to IDM download list.
So I searched all of the HKEY_CURRENT_USER\Software\DownloadManager subkeys for Url0 and saved the values to a list box using this code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
namespace IDMListSaver
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\DownloadManager");
string[] keys = key.GetSubKeyNames();
for (int i = 0; i <= key.SubKeyCount-1; i++)
{
key = key.OpenSubKey(keys[i]);
Object o = key.GetValue("Url0");
if (o != null)
{
listBox1.Items.Add(o);
}
key = Registry.CurrentUser.OpenSubKey("Software\\DownloadManager");
}
}
}
}
It definitely can get better, but it solved my problem until here.
So thanks again #Setsu
Related
I am re-wording this from an original post I made: I have two XML files, and they are related to a given year each. For example, 18/19 and 17/18. They conform to the same structure and below is small sample from one of these files. What I want is, in C#, to compare all records in these files where the Given Name, the Family Name, the NI Number and the Date of birth are the same, BUT the Learner Ref Number is different. I need to be able to compare, then push only these records into a data table so I can then push them into a spreadsheet (the spreadsheet bit I can do). I currently have the below as a starting block, but am still very much stuck.
Firstly, I have my Import button press for which:
private void Btn_Import_Click(object sender, RoutedEventArgs e)
{
ILRChecks.ILRReport.CrossYear();
}
Then this goes to look at the Class of which eventually pushes the file to my location:
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ILRValidation;
using InfExcelExtension;
namespace ILRChecks
{
internal static partial class ILRReport
{
internal static void CrossYear()
{
DataSet ds_CrossYearChecks =
ILRValidation.Validation.CrossYearChecks(Global.fileNames);
string output = Path.Combine(Global.foldername, "ULIN_Issues" +
".xlsx");
ds_CrossYearChecks.ToWorkBook(output);
}
}
}
And this is the bit I'm stuck on, which is the production of finding the differences:
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ILRValidation
{
public static partial class Validation
{
public static DataSet CrossYearChecks(DataSet ds_CrossYearChecks)
{
return CrossYearChecks(ds_CrossYearChecks);
}
public static DataSet CrossYearChecks(string[] xmlPath)
{
DataSet ds_xmlCrossYear = new DataSet();
return CrossYearChecks(ds_xmlCrossYear);
}
}
}
XML:
<Learner>
<LearnRefNumber></LearnRefNumber>
<ULN></ULN>
<FamilyName></FamilyName>
<GivenNames></GivenNames>
<DateOfBirth></DateOfBirth>
<Ethnicity></Ethnicity>
<Sex></Sex>
<LLDDHealthProb></LLDDHealthProb>
<NINumber></NINumber>
<PriorAttain></PriorAttain>
<MathGrade></MathGrade>
<EngGrade></EngGrade>
<PostcodePrior></PostcodePrior>
<Postcode></Postcode>
<AddLine1></AddLine1>
<AddLine3></AddLine3>
<Email></Email>
<LearnerEmploymentStatus>
<EmpStat>10</EmpStat>
<DateEmpStatApp>2015-09-01</DateEmpStatApp>
<EmpId>153421665</EmpId>
<EmploymentStatusMonitoring>
<ESMType>LOE</ESMType>
<ESMCode>4</ESMCode>
</EmploymentStatusMonitoring>
<EmploymentStatusMonitoring>
<ESMType>EII</ESMType>
<ESMCode>4</ESMCode>
</EmploymentStatusMonitoring>
</LearnerEmploymentStatus>
<LearningDelivery>
<LearnAimRef></LearnAimRef>
<AimType></AimType>
<AimSeqNumber></AimSeqNumber>
<LearnStartDate></LearnStartDate>
<LearnPlanEndDate></LearnPlanEndDate>
<FundModel></FundModel>
<ProgType></ProgType>
<StdCode></StdCode>
<DelLocPostCode></DelLocPostCode>
<CompStatus></CompStatus>
<SWSupAimId></SWSupAimId>
<LearningDeliveryFAM>
<LearnDelFAMType></LearnDelFAMType>
<LearnDelFAMCode></LearnDelFAMCode>
<LearnDelFAMDateFrom></LearnDelFAMDateFrom>
</LearningDeliveryFAM>
<LearningDeliveryFAM>
<LearnDelFAMType></LearnDelFAMType>
<LearnDelFAMCode></LearnDelFAMCode>
</LearningDeliveryFAM>
<LearningDeliveryFAM>
<LearnDelFAMType></LearnDelFAMType>
<LearnDelFAMCode></LearnDelFAMCode>
</LearningDeliveryFAM>
<LearningDeliveryFAM>
<LearnDelFAMType></LearnDelFAMType>
I have couple questions about referencing methods / variables between two or more *.cs files. I know that there are similar topics, but I still don't quite understand what is going on.
I'm using Visual Studio Community 2015.
So here is the problem. I have 2 files, those files are First.cs and Second.cs. They are saved in completely different, known locations on hard disc.
Inside First.cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Forum
{
class First
{
static void Main(string[] args)
{
}
public int GiveMeNumber()
{
return 5;
}
}
}
Inside Second.cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Forum
{
class Second
{
int number = // method from file First.cs
}
}
How do I access method GiveMeNumber() from First.cs in Second.cs as assignment for int number? How do I tell my compiler where are those files?
Thanks for any help :)
Like Alex said in his comment.
You can create a solution/project, add existing item, and browse to your first.cs and second.cs.
Mark both files with the public-keyword
for example:
namespace Forum
{
public class Second
{
int number = // method from file First.cs
}
}
Then both class can be used within each other.
So you could do
var first = new First();
var number = first.GiveMeNumber();
you probably want to do it the other way around, because I think you have a console app where your First class has a main-method.
does that help>?
I use this service to translate English word:
http://services.aonaware.com/DictService/DictService.asmx?op=Define
I add this link to my windows Form application by click right on References -> Add Service Reference -> and best the URL of service in Address field.
then I write this code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using هجوم_الكسر_الأعمى.ServiceReference1;
namespace هجوم_الكسر_الأعمى
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//Definition a = new Definition();
WordDefinition sv = new WordDefinition();
sv.Word="Go";
string b= sv.Word;
textBox1.Text = b; ;
}
}
}
The problem is that I don't have the result, I have the same world witch I write it "Go"?
You're not doing anything here, you're just creating an instance of WordDefinition locally that you set to the word you're trying to search for.
You need to invoke the service call, for example..
using (var dictionaryService = new ServiceReference1.DictServiceSoapClient("DictServiceSoap"))
{
var definition = dictionaryService.Define("Programming");
Console.WriteLine(definition.Definitions.First().WordDefinition);
}
I am not sure if I understand you, but if you would like to have result from sv.Word method I think you shloud try to check if there is some method with Result, for example: sv.WordResult and it will add event handler to this.
I'm a beginner in c#, currently attempting a windows form project. I've designed a form titled drugform. I use the dataset method to connect to the database. Here is my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Windows.Forms;
using drugstoreform.BaseInfoTableAdapters;
namespace drugstoreform
{
public partial class DrugForm : Form
{
int Row = -1;
public DrugForm()
{
InitializeComponent();
}
private void Register_click(object sender, EventArgs e)
{
try
{
dbm_Medecine db = new dbm_Medecine();
db.Insert(Convert.ToInt32(DrugCode.Text.Trim()), DrugName.Text.Trim(), Convert.ToString(HowUse.Text.Trim()), Convert.ToDecimal(price.Text.Trim()));
}
catch(SqlException ex)
{
}
When I click on the register button, I get this error: input string was not in a correct format.
You get the error inConvert.ToInt32 and/or Convert.ToDecimal because the input was invalid. You can use int.TryParse and decimal.TryParse to validate it:
int drugCode;
decimal price;
if (int.TryParse(DrugCode.Text.Trim(), out drugCode) && decimal.TryParse(price.Text.Trim(), out price))
{
db.Insert(drugCode, DrugName.Text.Trim(), HowUse.Text.Trim(), price);
}
In the if drugCode and price are initialized with the correct value. Otherwise you should provide an error message that the user should provide correct input.
Possible reasons: perhaps the user enters 2.6 but the computer uses , as decimal separator. Or DrugCode.Text or price.Text are simply empty.
I am working in project in which I have used vlc plugin v2. the path for my video is
axVLC.playlist.add(#"D:\My Project\Science\Resources\myvideo.mp4");
axVLC.playlist.play();
now the problem is when I build the project and give it to someone and he/she install it on his/her computer , it show exception that video path is wrong. I am sure that path is not suitable as my the video path in my project is D:... and he/she installed it on C.
So my question is that is there any way to give it common path by which user don`t face such kind of error
Import IO
Using System.IO;
then declare a string that will reference to your video folder
string AbsoluteRef;
use this code in your form load
if (System.Diagnostics.Debugger.IsAttached)
{
AbsoluteRef = Path.GetFullPath(Application.StartupPath + "\\..\\..\\Resources\\");
}
else
{
AbsoluteRef = Application.StartupPath + "\\Resources\\";
}
Now declare a string for your video or which ever file like
string vlcvideo;
now add the two together
vlcvideo = AbsoluteRef & "myvideo.mp4";
Finnally add all this into your vlc plugin
axVLC.playlist.add(vlcvideo);
Complete Code looks like so.
using Microsoft.VisualBasic;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Input;
using yournamespace.Forms;
using System.IO;
namespace yourNameSpace
{
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
string AbsoluteRef = null;
private void frmMain_Load(object sender, EventArgs e)
{
if (System.Diagnostics.Debugger.IsAttached)
{
AbsoluteRef = Path.GetFullPath(Application.StartupPath + "\\..\\..\\Resources\\");
}
else
{
AbsoluteRef = Application.StartupPath + "\\Resources\\";
}
string vlcVideo = AbsoluteRef + "myvideo.mp4";
axVLC.playlist.add(vlcvideo);
}