logo
down
shadow

How to download an .EXE file from a website?


How to download an .EXE file from a website?

By : anisaha
Date : November 14 2020, 04:51 PM
With these it helps You can alter your code a bit to get it working. DownloadFileAsync is asynchronous call so may be your thread executing it ending before your download has completed.
You need to attach a handler to find out if the download has completed if you are using async
code :
    [TestMethod]
    public void TestDownload()
    {
        var webClient = new WebClient();
        webClient.DownloadProgressChanged += webClient_DownloadProgressChanged;
        webClient.DownloadFileAsync(new Uri("https://www.telerik.com/downloads/productfiles/btmba/TelerikJustDecompileSetup_2014.3.1021.0.exe"), @"c:\temp\justdecompile.exe");

        // just to show in a Unit Test.. Not required in actual code
        Thread.Sleep(10000); 

        var info = new FileInfo(@"c:\temp\justdecompile.exe");
        Assert.IsTrue(info.Length > 0);
    }
    void webClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
    {
        Debug.WriteLine(String.Format("{0}    downloaded {1} of {2} bytes. {3} % complete...",
                    (string)e.UserState,
                    e.BytesReceived,
                    e.TotalBytesToReceive,
                    e.ProgressPercentage));
    }


Share : facebook icon twitter icon
A PHP script to let users download a file from my website without revealing the actual file link in my website?

A PHP script to let users download a file from my website without revealing the actual file link in my website?


By : user2138617
Date : March 29 2020, 07:55 AM
Can I download a file from a website with a download link? Visual Basic

Can I download a file from a website with a download link? Visual Basic


By : user2937811
Date : March 29 2020, 07:55 AM
Does that help Okay. So here's a possible solution for you.
Sadly it only works if the link is complete. (Starts with http:// etc...)
code :
Imports System.Text.RegularExpressions
Imports System.IO

Public Class Form1
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        ScanForZIPs()
    End Sub

    Private Sub ScanForZIPs()
        Dim Reader As New StreamReader("<path to the downloaded webpage>")
        Dim HTMLSource As String = Reader.ReadToEnd()

        Dim Pattern As String = "(?<Protocol>\w+):\/\/(?<Domain>[\w@][\w.:@]+)\/?[\w\.?=%&=\-@/$,]*" 'Pattern, which the Regex will use in order to match links in the webpage.
        'Credits to IronRazerz (https://social.msdn.microsoft.com/profile/ironrazerz/?ws=usercard-mini) for giving me a fully working pattern.
        Dim RgEx As New Regex(Pattern, RegexOptions.IgnoreCase) 'Define the Regex.

        Dim mc As MatchCollection = RgEx.Matches(HTMLSource) 'Check for matches in the HTML source.

        Dim MatchList As New List(Of String) 'List of strings for the matched links.

        For Each m As Match In mc 'Loop through each match.
            MatchList.Add(m.Value) 'Add the value (link) of each match to the MatchList.
        Next

        Dim ZipsList As New List(Of String) 'List of links that ends with .zip.

        For Each s As String In MatchList 'Loop through each string in MatchList.
            If s.ToLower.ToString.EndsWith(".zip") = True Then 'Check if the link ends with .zip.
                ZipsList.Add(s) 'Add the link to the list.
            End If
        Next

        MessageBox.Show(ZipsList.Count & " .zip files found", "", MessageBoxButtons.OK, MessageBoxIcon.Information) 'Display how many .zip files were found on the page.

        Dim SelectZip As New SelectDownload 'Define a new download form.
        For Each z As String In ZipsList 'Loop through the found .zip links.
            SelectZip.ListBox1.Items.Add(z) 'Add them to the list in the SelectZip form.
        Next
        SelectZip.ListBox1.HorizontalScrollbar = True 'Horizontall scrollbar in SelectZip's ListBox.
        SelectZip.ShowDialog() 'Display the SelectZip form.
    End Sub
End Class
download file from another codeigniter website through our download function

download file from another codeigniter website through our download function


By : user3196388
Date : March 29 2020, 07:55 AM
I hope this helps you . You are facing CORSS problem. Cross-origin resource sharing (CORS) is a mechanism that allows many resources (e.g. fonts, JavaScript, etc.) on a web page to be requested from another domain outside the domain from which the resource originated You have to enable CORSS on Apache server or in your php header
code :
<?php
 header("Access-Control-Allow-Origin: *");
<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin http://www.yourfirstsite.com  
    Header set Access-Control-Allow-Credentials true
</IfModule>
Is it possible to download something from another website into a zip file download supplied by my company based on form

Is it possible to download something from another website into a zip file download supplied by my company based on form


By : Ozzy
Date : March 29 2020, 07:55 AM
With these it helps Yes, you can load the zip file using jszip. Than download the video using AJAX and add it to the the zip. All of this happens in the browser.
code :
JSZipUtils.getBinaryContent('path/to/content.zip', function(err, data) {
  if(err) throw err; // or handle err

  var zip = new JSZip(data);

  var request = new XMLHttpRequest();
  request.open('GET', 'https://vimeo.com/link/to/download', true);

  request.onload = function() {
    var data = request.responseText;

    zip.folder('Videos').file('video.mp4', data); // Add the video file

    var blob = zip.generate({type:"blob"});
    saveAs(blob, "content.zip"); // Present zip as download
  };

  request.send();
}
Not able to download file using webclient, but I am able to download it manually from the website

Not able to download file using webclient, but I am able to download it manually from the website


By : Jonathan Foxman Cont
Date : March 29 2020, 07:55 AM
will help you I've checked the url you gave and see that when you select the "Date(DD-MM-YYYY)" and "Select Report" drop-down options and click on "Get Data", there is a GET request send to https://www.nseindia.com/ArchieveSearch with three parameter like this: "?h_filetype=fobhav&date=02-04-2018§ion=FO". And this GET request returns:
code :
<p class="archive_title">F&O - Bhavcopy for 02-04-2018 </p><br>
<br><table cellpadding=5>
<tr>
<td class=t0><a href=/content/historical/DERIVATIVES/2018/APR/fo02APR2018bhav.csv.zip target=new>fo02APR2018bhav.csv.zip</a></td></tr>
<tr>
</table>
</td></tr>
</table>
        string source_location2 = "https://www.nseindia.com/ArchieveSearch";
        Uri uu2 = new Uri(source_location2);

        using (WebClient fileReader = new WebClient())
        {
            try
            {
                var ua = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36";
                fileReader.Headers.Add(HttpRequestHeader.UserAgent, ua);
                fileReader.Headers["Accept"] = "/";
                fileReader.QueryString.Add("h_filetype", "fobhav");
                fileReader.QueryString.Add("date", "02-04-2018");
                fileReader.QueryString.Add("section", "FO");
                var response = fileReader.DownloadString(uu2);
                //using Html Agility Pack to parse the response and get the download link. you need to add this package through nuget package manager to project for this code to work.
                var htmlDoc = new HtmlDocument();
                htmlDoc.LoadHtml(response);
                var fileLink = htmlDoc.DocumentNode.SelectSingleNode("//table//tr//td//a").Attributes["href"].Value;
                //now sending the actual file request...
                var fileReader2 = new WebClient();
                fileReader2.Headers.Add(HttpRequestHeader.UserAgent, ua);
                fileReader2.Headers["Accept"] = "/";
                fileReader2.DownloadFile(new Uri("https://www.nseindia.com" + fileLink), @"d:\notworking.zip");
                fileReader2.Dispose();

            }
            catch(Exception e)
            {
                throw e;
            }
        }
Related Posts Related Posts :
  • Marshal.Copy attempted to read or write protected memory At Random Times
  • Restrict Type variable to specific class or subclass
  • Horizontal text alignment in a PdfPCell
  • C# crashing with Form.show() command, ObjectDisposedException - Deeper look / explanation please
  • Will the result of a LINQ query always be guaranteed to be in the correct order?
  • "Could not find default endpoint element that references contract"
  • Umbraco Request.QueryString is null if it's the first time the page is loaded
  • Error inconsistent accessibility method C#
  • How to program Intel Xeon Phi with C#?
  • remove nested element using regular expression
  • Is there a C# alternative to Java's vararg parameters?
  • Clear particular column values in DataTable
  • how to add event handler to programatically created checkboxes
  • Cannot apply indexing with [] to an expression of type 'System.Collections.Specialized.NameValueCollection'
  • Check for key in pre-existing dictionary in case insensitive manner
  • How to remove year from datetime object?
  • Accessing Settings in different ways
  • "This project is empty" error in Sonarqube
  • How to create reusable icon menu in Xamarin
  • Value Cannot be null in Ado.Net connectivity
  • Adding a custom/dynamic attribute when using XSD.exe
  • How to convert object to correct type
  • Automatically sign out from Forms Authentication in ASP.NET when browser is closed
  • Can a WCF service support both Buffered and Streamed transfer modes?
  • Verify a CA Certificate with a public key in C#
  • How to invoke a Web Service that requires the "patch" verb using the C# WebClient wrapper?
  • Proper way a implementing property based on generic type
  • Closing a form that is created in another thread
  • How Can You Bind a List<String> to a StackPanel
  • WPF Application Update Best Practices - Architectural Explanation
  • System.UnauthorizedAccessException in Server.MapPath()
  • Connecting and Using SQL Compact Edition in a WPF application
  • C#: weird ref in constructor to behave like "virtual field"
  • C# XDocument Load with multiple roots
  • How to decide what goes in the Domain or Application Project in a "DDD" solution?
  • How to get/set a property of an interface that is not always implemented
  • Read-only array field in unsafe struct
  • i got "Invalid attempt to call Read when reader is closed" when using sqldatareader how to solve it in a three
  • Why should I encapsulate objects in using if there is garbage collection
  • How to load Word document from byte array
  • Caliburn.Micro and ContextMenu for DataGrid Row
  • Linq "join" with a IList<T> getting "Error Unable to create a constant value.."
  • How to draw red wavy line under words in RichTextBox c# winform
  • HttpPostedFileBase returns Null MVC3
  • Refresh Dropdownlist in webform
  • How to convert serialized byte array back to its text form
  • How to do a loop to check all the variables at the same time for C#?
  • Facebook Sentiment Analysis API
  • Counting occurrences of specific letters in string
  • Module 'System.Data.Linq' Version=4.0.0.0, Culture=neutral, Publickeytoken=b77a5c561934e089' should be referenced
  • C# MVC Dynamically create view model
  • Get Executing Path of C# application when using nunit with Jenkins
  • GDI count stable near 100 but Handle count keep increasing
  • Problem adding string value to ViewBag from an MVC Action using TempData
  • Reading Excel file on condition
  • what is windows programming from C++, C# and Java perspective?
  • How to deal with C# object references in MongoDB?
  • How to create a list from filtering 2 lists with linq to object
  • Webclient calls to DownloadString cause my app to freeze
  • How to create a JSON WebService in c# ASP.Net with a valid JSON output and query with JQuery/Ajax
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org