Skip to content

Instantly share code, notes, and snippets.

@hamxiaoz
Last active February 17, 2016 23:34
Show Gist options
  • Save hamxiaoz/36729bfea4a37301c0e5 to your computer and use it in GitHub Desktop.
Save hamxiaoz/36729bfea4a37301c0e5 to your computer and use it in GitHub Desktop.
How to use [isxdl.dll](http://woohaeng.com.ne.kr/docs/isxdl.htm) to download files in C#?
[DllImport("isxdl.dll")]
static extern Int32 isxdl_Download(IntPtr hWndParent, String pszURL, String pszFileName);
[DllImport("isxdl.dll")]
static extern Int32 isxdl_SetOption(String option, String value);
private void button_download_Click(object sender, EventArgs e)
{
var fileUrl = "REPLACE_ME";
// use dll to download
String downloadFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "COMPANY", "Downloaded Updates");
if (!Directory.Exists(downloadFolder)) Directory.CreateDirectory(downloadFolder);
String downloadedFile = Path.Combine(downloadFolder, Path.GetFileName(fileUrl));
isxdl_SetOption("title", "Downloading Updates");
isxdl_SetOption("label", "Downloading Updates...");
Int32 result = isxdl_Download(IntPtr.Zero, fileUrl, downloadedFile);
if (result == 1)
{
// file downloaded
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment