I used 2 resources from NuGet Dropbox.api and System.IO.compression.ZipFile
The way I have my program set up is to directly publish to my dropbox api folder but, you could migrate the updates you want manually as well.
You can set up a DropBox api account at: https://www.dropbox.com/developers
Note: This does require the program to be initially installed from the downloads folder due to the quirks of ClickOnce, you can always change the path to your liking as well.
I don't know if anyone could use this here but I figured id put it out there as a relatively easy way to set up updates for ClickOnce software.
Code:Imports Dropbox.Api Public Class Form1 Public Version as String Public Update as Boolean 'Gets the Currents version of your program and checks it against the latest version the the dropbox folder Private Async Function CheckVersion() As Task Using drp = New DropboxClient("DropBoxToken") Dim Ver = My.Application.Info.AssemblyName +"_" + Version.Replace(".", "_") Try Dim VersionsonDB = Await drp.Files.ListFolderAsync("/Application Files") Latest = (VersionsonDB .Entries(VersionsonDB .Entries.Count - 1).Name) If Latest = Ver Then Else If MsgBox("Update Found Would you like to Download it?", MsgBoxStyle.YesNo, My.Application.Info.AssemblyName +" Update") = MsgBoxResult.Yes Then Update = True Else Update = False End If End If Catch e As ApiException(Of Files.GetMetadataError) MsgBox(e.Message) End Try End Using End Function 'Downloads the needed files to update your program Private Async Function downloadUpdate() As Task Dim path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) & "\Downloads\" If System.IO.File.Exists(path + "setup.exe") Then System.IO.File.Delete(path + "setup.exe") End If If System.IO.File.Exists(path + My.Application.Info.AssemblyName + ".application") Then System.IO.File.Delete(path + My.Application.Info.AssemblyName + ".application") End If If System.IO.Directory.Exists(path + "Application Files") Then System.IO.Directory.Delete(path + "Application Files", True) End If Using drp = New DropboxClient("DropBoxToken") Using response = Await drp.Files.DownloadAsync("/setup.exe") System.IO.File.WriteAllBytes(path + "setup.exe", Await response.GetContentAsByteArrayAsync) End Using Using response = Await drp.Files.DownloadAsync("/"+My.Application.Info.AssemblyName + ".application") System.IO.File.WriteAllBytes(path + My.Application.Info.AssemblyName+ ".application", Await response.GetContentAsByteArrayAsync) End Using Using response = Await drp.Files.DownloadZipAsync("/Application Files/" + Latest) System.IO.Directory.CreateDirectory(path + "Application Files") System.IO.File.WriteAllBytes(path + "Application Files/Latest.zip", Await response.GetContentAsByteArrayAsync) System.IO.Compression.ZipFile.ExtractToDirectory(path + "Application Files/Latest.zip", path + "Application Files/") End Using End Using End Function Public Sub CheckForUpdate() Version = My.Application.Deployment.CurrentVersion Dim path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) & "\Downloads\" Dim task1 = Task.Run(Function() CheckVersion()) task1.Wait() If Update Then task1 = Task.Run(Function() downloadUpdate()) task1.Wait() Process.Start(path + "setup.exe") Me.Close() Exit Sub End If End Sub End Class


Reply With Quote