Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed May 08, 2021 at 06:36 PM by Controser for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Controser · May 08, 2021 at 03:36 AM · stringdownloadurlfilenamewebclient

Can you download a file from a URL without the full file name?

So as you can see below I am downloading a file from VRChat's website. Everything works when I use the full name of the file. However, their filenames change every time they update the file. For instance, the file name currently looks like this:

"VRCSDK2-2021.04.21.11.58_Public.unitypackage".

If they update the file then the name change breaks my code. Is there a way to write my file name so that it will not break when they update? Such as a way to have the code look for any file starting with "VRCSDK2"? Thanks for all the help!

         private static string sdkStart = "https://files.vrchat.cloud/sdk/";
  
 ...
  
         private static void DownloadSDK(string assetName)
         {
             GetPath();
             WebClient w = new WebClient();
             w.Headers.Set(HttpRequestHeader.UserAgent, "Webkit Gecko wHTTPS (Keep Alive 55)");
             w.QueryString.Add("assetName", assetName);
             w.DownloadFileCompleted += FileDownloadCompleted;
             w.DownloadProgressChanged += FileDownloadProgress;
             string url = sdkStart + assetName;
             w.DownloadFileAsync(new Uri(url), Path + assetName);
         }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
0

Answer by Controser · May 08, 2021 at 06:35 PM

Never mind! I found the solution with someone else's help. For those who may need to know, if you have a link that redirects to the download then you can do this:

 private static void DoDownload()
 {
     var w = new WebClient();
     w.Headers.Set(HttpRequestHeader.UserAgent, "Webkit Gecko wHTTPS (Keep Alive 55)");
     w.DownloadFileCompleted += FileDownloadCompleted;
     w.DownloadProgressChanged += FileDownloadProgress;
     var url = "link here that is the redirect";
     w.DownloadFileAsync(new Uri(url), Application.dataPath + "/assetName.unitypackage");
 }
 private static void FileDownloadProgress(object sender, DownloadProgressChangedEventArgs e) => Debug.Log($"Progress: {e.ProgressPercentage}%");
 private static void FileDownloadCompleted(object sender, AsyncCompletedEventArgs e) => Debug.Log("Done.");
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

117 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Downloading unity 3 4 Answers

while using Handheld.PlayFullScreenMovie playing url video stream, where it store the stream? 0 Answers

Unity 5 Download AssetBundles from server via URL. 2 Answers

easy Code does not work 0 Answers

Loading scene from assetbundle (url) 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges