| View previous topic :: View next topic |
| Author |
Message |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Wed May 14, 2008 8:09 am Post subject: [C#]"URI Formats are not supported" |
|
|
Hi,
I'm trying to load a picture from the internet to a picture box, but I get "URI Formats are not supported" exception.
I tried using System.Net to see if I can download the picture or something, but I really don't know how to do it...
I did:
| Code: | | this.BackgroundImage = Image.FromFile("http://....com/....png"); |
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Wed May 14, 2008 4:54 pm Post subject: |
|
|
You can't pass a URL and expect it to download
you HAVE to call the downloading function and passing that to it.
_________________
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Wed May 14, 2008 6:09 pm Post subject: |
|
|
| blankrider wrote: | You can't pass a URL and expect it to download
you HAVE to call the downloading function and passing that to it. |
As in getting a parameter using another function.
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Wed May 14, 2008 7:13 pm Post subject: |
|
|
I think it's just a simple DownloadFile call o.o
URLDownloadToFile
This will download the file to a file on the harddrive then you can call that file.
C Example
| Code: | #include <urlmon.h>
#include <stdio.h>
IBindStatusCallback *stat;
char* file = "http://img174.imageshack.us/img174/9614/lawlep9.jpg";
int main(){
if(URLDownloadToFile(0,file,"pic.jpg",0,stat))
{
MessageBox(0,"Error:\nFile Not Found or you are offline","Error",MB_OK | MB_ICONERROR);
return 1;
}
return 0;
} |
Then of course you could always delete the image RIGHT after you use it and the user wouldn't know
_________________
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Wed May 14, 2008 8:12 pm Post subject: |
|
|
Here's some C# that might help you:
| Code: |
//using System.Net;
WebClient Client = new WebClient ();
Client.DownloadFile("website", "path");
picMyPicture.Picture = "path"; //I have no idea how to work with these, so you're on your own here; just sorta threw you a bone. =P
|
_________________
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Thu May 15, 2008 11:49 am Post subject: |
|
|
| blankrider wrote: | I think it's just a simple DownloadFile call o.o
URLDownloadToFile
This will download the file to a file on the harddrive then you can call that file.
C Example
| Code: | #include <urlmon.h>
#include <stdio.h>
IBindStatusCallback *stat;
char* file = "http://img174.imageshack.us/img174/9614/lawlep9.jpg";
int main(){
if(URLDownloadToFile(0,file,"pic.jpg",0,stat))
{
MessageBox(0,"Error:\nFile Not Found or you are offline","Error",MB_OK | MB_ICONERROR);
return 1;
}
return 0;
} |
Then of course you could always delete the image RIGHT after you use it and the user wouldn't know |
| samuri25404 wrote: | Here's some C# that might help you:
| Code: |
//using System.Net;
WebClient Client = new WebClient ();
Client.DownloadFile("website", "path");
picMyPicture.Picture = "path"; //I have no idea how to work with these, so you're on your own here; just sorta threw you a bone. =P
|
|
Thanks you two.
Edit: not sure how to convert URLDownloadToFile to C# and where does WebClient download the files to? O_O
|
|
| Back to top |
|
 |
|