Question how to use file from website

Carat1

New member
Joined
Jul 15, 2019
Messages
4
Programming Experience
Beginner
hello, i need help on using a file i downloaded using the code below. currently im using My.Resources for my DLL file, but i want to use the DLL from my github because i do updates on my file periodically.
Code:
My.Computer.Network.DownloadFile("https://github.com/Carat1/File/raw/master/File.dll"
IO.File.WriteAllBytes(tempFilePath, My.Resources.File)
how would i be able to code this as the second argument in WriteAllBytes needs to be a byte?
because i can't just do something like:
Code:
IO.File.WriteAllBytes(tempFilePath, "https://github.com/Carat1/File/raw/master/File.dll")
 

Carat1

New member
Joined
Jul 15, 2019
Messages
4
Programming Experience
Beginner

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,108
Location
Sydney, Australia
Programming Experience
10+
Your "question" doesn't really make sense. That DownloadFile method will download data from a remote location to a file on your machine. Once that's done, it is a file like any other and you would use it like any other file. The fact that it was downloaded is irrelevant to how you use it.

That has no relationship whatsoever to WriteAllBytes. That method will save the contents of a Byte array to a file. Again, once that's done, it's a file like any other.

These are two methods of creating a local file. They are not used together. Please provide a FULL and CLEAR explanation of what you're trying to achieve, rather than how you're trying to achieve it. If we know that then we can tell you the best way to achieve it. It will not involve calling DownloadFile and WriteAllBytes together because that's not the best way to do anything useful.
 

Carat1

New member
Joined
Jul 15, 2019
Messages
4
Programming Experience
Beginner
Your "question" doesn't really make sense. That DownloadFile method will download data from a remote location to a file on your machine. Once that's done, it is a file like any other and you would use it like any other file. The fact that it was downloaded is irrelevant to how you use it.

That has no relationship whatsoever to WriteAllBytes. That method will save the contents of a Byte array to a file. Again, once that's done, it's a file like any other.

These are two methods of creating a local file. They are not used together. Please provide a FULL and CLEAR explanation of what you're trying to achieve, rather than how you're trying to achieve it. If we know that then we can tell you the best way to achieve it. It will not involve calling DownloadFile and WriteAllBytes together because that's not the best way to do anything useful.
i want to use the DLL as a resource because when i use DownloadFile, i can see that it places a file at the same directory as my exe, which is something i don't want. when i use WriteAllBytes, it doesn't "create" the file, and it uses the DLL directly from My.Resources. i was wondering if i can use the DownloadFile method and somehow put that in my resources?
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,286
Location
Norway
Programming Experience
10+
It is you who specifies where to download a file. No, you can't add it to resources, they are added only when the application is compiled. Of course File.WriteAllBytes creates a file, that's its single purpose.
 

Carat1

New member
Joined
Jul 15, 2019
Messages
4
Programming Experience
Beginner
oh i see, but when i used WriteAllBytes, i didn't see a file being created on my desktop unlike DownloadFile, unless the file is being hidden in a folder somewhere
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,108
Location
Sydney, Australia
Programming Experience
10+
oh i see, but when i used WriteAllBytes, i didn't see a file being created on my desktop unlike DownloadFile, unless the file is being hidden in a folder somewhere
Then you must have looked in the wrong place. You are clearly misunderstanding what's going on here. When you call DownloadFile, binary data is downloaded from the remote location and written to a file that you specify. When you call WriteAllBytes, the binary data contained in the Byte array you provide is being written to a file that you specify. When you say this:
it uses the DLL directly from My.Resources
I don;t know exactly what "it" you're referring to, because you haven't shown us the relevant code. I assure you though, nothing is being used "directly from My.Resources".
 
Top Bottom