Matt
Matt

Reputation: 170

.NET programmatic file download for Deployment/Update

I have spent the last several days attempting to setup a home FTP server, but my firewall is giving me a hard time.

My goal is to emulate the functionality of a Click-Once application in a Portable .NET application. I have a finished portable EXE file with several read/write folders of data in the same directory being accessed at run time with My.Application.info.directorypath. For this reason I don't want to do a published application with an installation because many users don't have write privileges to their program files directory. In addition I have users using WINE on Mac/Linux as well as XP users. I think it will be problematic to try and get the same compatibility I have presently if I break away from being portable.

My plan is to write a second application to function as a launcher/updater. It will use a web client to read a hosted file with the current software version number. If its out of date it will prompt the user and then use WebClient.DownloadFile to download a zipped package of the newest software. Replace the old with the new and then launch the application.

The only problem is this is very virus'esk... I don't think its possible do a programmatic file download and have it just replace file in the background.

Does anyone have any good deployment tricks on how they would handle this situation? Also Anyone have a good suggestion for a file hosting location that can be read programmatically (I can use Github, but I imagine that is frowned upon...)

I am considering using Squirrel.Windows, but then none of my WINE or XP users will be able to use it.

Upvotes: 1

Views: 250

Answers (1)

Jason Bayldon
Jason Bayldon

Reputation: 1296

You could potentially have the Update Application act as a "launcher" that verifies if an update is required, optionally downloads it to a subfolder and unpacks it, and then runs the actual application.

SomeLauncher.exe
-> application sub-folder -> TheAppToRun.exe

I think this way you avoid having problems locking the files.

Edit: WebClient https://msdn.microsoft.com/en-us/library/ez801hhe(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2

    Dim client As New System.Net.WebClient()
    client.DownloadFile("http://path/to/file.zip", "c:\some\path")
    client.Dispose();

Upvotes: 2

Related Questions