PC Review


Reply
Thread Tools Rate Thread

How can I save to a file to the PDA?

 
 
Me
Guest
Posts: n/a
 
      9th Mar 2004
I downloaded a JPG stream from a URI using a WebRequest

Request = WebRequest.Create(http://myWebpage.jpg)
Response = Request.GetResponse
ResponseStream = Response.GetResponseStream

I then convert the response to a bitmap file
PictureBox1.Image = New Bitmap(ResponseStream)

What I would like to do now is to to save the file to the PDA?

Is there any straightforward, easy way to do this in CF?

Thanks,

Gigi


 
Reply With Quote
 
 
 
 
Lloyd Dupont
Guest
Posts: n/a
 
      10th Mar 2004
I suggest you save the ResposeStream content in a byte[]
and
1. create a bitmap from these byte[](s)
2. save this byte[](s) in a file

"Me" <(E-Mail Removed)> wrote in message
news:JEs3c.56934$(E-Mail Removed)...
> I downloaded a JPG stream from a URI using a WebRequest
>
> Request = WebRequest.Create(http://myWebpage.jpg)
> Response = Request.GetResponse
> ResponseStream = Response.GetResponseStream
>
> I then convert the response to a bitmap file
> PictureBox1.Image = New Bitmap(ResponseStream)
>
> What I would like to do now is to to save the file to the PDA?
>
> Is there any straightforward, easy way to do this in CF?
>
> Thanks,
>
> Gigi
>
>



 
Reply With Quote
 
Me
Guest
Posts: n/a
 
      10th Mar 2004
Thanks Lloyd.

Can you recommend where I can get any such code samples in vb.net?


Thanks,

Gigi

"Lloyd Dupont" <net.galador@ld> wrote in message
news:(E-Mail Removed)...
> I suggest you save the ResposeStream content in a byte[]
> and
> 1. create a bitmap from these byte[](s)
> 2. save this byte[](s) in a file
>
> "Me" <(E-Mail Removed)> wrote in message
> news:JEs3c.56934$(E-Mail Removed)...
> > I downloaded a JPG stream from a URI using a WebRequest
> >
> > Request = WebRequest.Create(http://myWebpage.jpg)
> > Response = Request.GetResponse
> > ResponseStream = Response.GetResponseStream
> >
> > I then convert the response to a bitmap file
> > PictureBox1.Image = New Bitmap(ResponseStream)
> >
> > What I would like to do now is to to save the file to the PDA?
> >
> > Is there any straightforward, easy way to do this in CF?
> >
> > Thanks,
> >
> > Gigi
> >
> >

>
>



 
Reply With Quote
 
Lloyd Dupont
Guest
Posts: n/a
 
      10th Mar 2004
not in VB.NET
but just out of mind here is how I will do in (C# looking) pseudo code

Request = WebRequest.Create(http://myWebpage.jpg)
Response = Request.GetResponse
ResponseStream = Response.GetResponseStream
byte[] buf = new byte[Response.ContentLength];
int nread, pos=0, len = buf.Length;
while(len > 0)
{
nread = ResponseStream.Read(buf, pos, len);
if(nread > 0)
{
pos += nread;
len -= nread;
}
}

Bitmap b = new Bitmap(new MemoryStream(buf));
FileStream fs = new FileStream("myfile.jpg");
fs.Write(buf, 0, buf.Length);
fs.Close();

"Me" <(E-Mail Removed)> wrote in message
news:Brt3c.33381$(E-Mail Removed)...
> Thanks Lloyd.
>
> Can you recommend where I can get any such code samples in vb.net?
>
>
> Thanks,
>
> Gigi
>
> "Lloyd Dupont" <net.galador@ld> wrote in message
> news:(E-Mail Removed)...
> > I suggest you save the ResposeStream content in a byte[]
> > and
> > 1. create a bitmap from these byte[](s)
> > 2. save this byte[](s) in a file
> >
> > "Me" <(E-Mail Removed)> wrote in message
> > news:JEs3c.56934$(E-Mail Removed)...
> > > I downloaded a JPG stream from a URI using a WebRequest
> > >
> > > Request = WebRequest.Create(http://myWebpage.jpg)
> > > Response = Request.GetResponse
> > > ResponseStream = Response.GetResponseStream
> > >
> > > I then convert the response to a bitmap file
> > > PictureBox1.Image = New Bitmap(ResponseStream)
> > >
> > > What I would like to do now is to to save the file to the PDA?
> > >
> > > Is there any straightforward, easy way to do this in CF?
> > >
> > > Thanks,
> > >
> > > Gigi
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Muhammad Arif
Guest
Posts: n/a
 
      10th Mar 2004
Visit the following URL
http://www.opennetcf.org/Forums/topic.asp?TOPIC_ID=385

Regards,
Arif


"Me" <(E-Mail Removed)> wrote in message news:<JEs3c.56934$(E-Mail Removed)>...
> I downloaded a JPG stream from a URI using a WebRequest
>
> Request = WebRequest.Create(http://myWebpage.jpg)
> Response = Request.GetResponse
> ResponseStream = Response.GetResponseStream
>
> I then convert the response to a bitmap file
> PictureBox1.Image = New Bitmap(ResponseStream)
>
> What I would like to do now is to to save the file to the PDA?
>
> Is there any straightforward, easy way to do this in CF?
>
> Thanks,
>
> Gigi

 
Reply With Quote
 
Me
Guest
Posts: n/a
 
      13th Mar 2004
Lloyd,

Thanks for your response. I looked at your code and the code in the Stream
Class. I actually tried both, but the problem that I am now having is that
the stream that :

? ResponseStream
{System.Net.ConnectStream}
[System.Net.ConnectStream]: {System.Net.ConnectStream}
CanRead: True
CanSeek: False
CanWrite: False
Length: <error: an exception of type: {System.NotSupportedException}
occurred>
Null: {System.IO.Stream.NullStream}
Position: <error: an exception of type: {System.NotSupportedException}
occurred>.

I can load the stream into the bitmap and display it, but I can only
intermittantly load it into the Read method and put it in the byte buffer.

Any suggestions?

Thanks,

Gigi

"Lloyd Dupont" <net.galador@ld> wrote in message
news:(E-Mail Removed)...
> not in VB.NET
> but just out of mind here is how I will do in (C# looking) pseudo code
>
> Request = WebRequest.Create(http://myWebpage.jpg)
> Response = Request.GetResponse
> ResponseStream = Response.GetResponseStream
> byte[] buf = new byte[Response.ContentLength];
> int nread, pos=0, len = buf.Length;
> while(len > 0)
> {
> nread = ResponseStream.Read(buf, pos, len);
> if(nread > 0)
> {
> pos += nread;
> len -= nread;
> }
> }
>
> Bitmap b = new Bitmap(new MemoryStream(buf));
> FileStream fs = new FileStream("myfile.jpg");
> fs.Write(buf, 0, buf.Length);
> fs.Close();
>
> "Me" <(E-Mail Removed)> wrote in message
> news:Brt3c.33381$(E-Mail Removed)...
> > Thanks Lloyd.
> >
> > Can you recommend where I can get any such code samples in vb.net?
> >
> >
> > Thanks,
> >
> > Gigi
> >
> > "Lloyd Dupont" <net.galador@ld> wrote in message
> > news:(E-Mail Removed)...
> > > I suggest you save the ResposeStream content in a byte[]
> > > and
> > > 1. create a bitmap from these byte[](s)
> > > 2. save this byte[](s) in a file
> > >
> > > "Me" <(E-Mail Removed)> wrote in message
> > > news:JEs3c.56934$(E-Mail Removed)...
> > > > I downloaded a JPG stream from a URI using a WebRequest
> > > >
> > > > Request = WebRequest.Create(http://myWebpage.jpg)
> > > > Response = Request.GetResponse
> > > > ResponseStream = Response.GetResponseStream
> > > >
> > > > I then convert the response to a bitmap file
> > > > PictureBox1.Image = New Bitmap(ResponseStream)
> > > >
> > > > What I would like to do now is to to save the file to the PDA?
> > > >
> > > > Is there any straightforward, easy way to do this in CF?
> > > >
> > > > Thanks,
> > > >
> > > > Gigi
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Me
Guest
Posts: n/a
 
      13th Mar 2004
In spite of the messages that I received, I was finally able to get the
stream loaded into the bitmap file and saved to disk. By reading the stream
into a PictureBox.Image FIRST, I was unable to read it again into another
stream because the original jpeg file was readable only, and not seekable.
Thus, I could not place the pointer from the end of file to the beginning of
file.

Simply reading the jpeg into a stream and loading it into the file first,
then using the contents of the file to display to the PictureBox works fine
ALMOST.

I works like a charm on the Desktop.

I'm getting an error when I try to load the file on the PDA although a file
is indeed stored. I'm still working through this issue.

I will let you all know how I do.

Thanks,

Gigi

"Me" <(E-Mail Removed)> wrote in message
news:eeu4c.58059$(E-Mail Removed)...
> Lloyd,
>
> Thanks for your response. I looked at your code and the code in the

Stream
> Class. I actually tried both, but the problem that I am now having is

that
> the stream that :
>
> ? ResponseStream
> {System.Net.ConnectStream}
> [System.Net.ConnectStream]: {System.Net.ConnectStream}
> CanRead: True
> CanSeek: False
> CanWrite: False
> Length: <error: an exception of type: {System.NotSupportedException}
> occurred>
> Null: {System.IO.Stream.NullStream}
> Position: <error: an exception of type: {System.NotSupportedException}
> occurred>.
>
> I can load the stream into the bitmap and display it, but I can only
> intermittantly load it into the Read method and put it in the byte buffer.
>
> Any suggestions?
>
> Thanks,
>
> Gigi
>
> "Lloyd Dupont" <net.galador@ld> wrote in message
> news:(E-Mail Removed)...
> > not in VB.NET
> > but just out of mind here is how I will do in (C# looking) pseudo code
> >
> > Request = WebRequest.Create(http://myWebpage.jpg)
> > Response = Request.GetResponse
> > ResponseStream = Response.GetResponseStream
> > byte[] buf = new byte[Response.ContentLength];
> > int nread, pos=0, len = buf.Length;
> > while(len > 0)
> > {
> > nread = ResponseStream.Read(buf, pos, len);
> > if(nread > 0)
> > {
> > pos += nread;
> > len -= nread;
> > }
> > }
> >
> > Bitmap b = new Bitmap(new MemoryStream(buf));
> > FileStream fs = new FileStream("myfile.jpg");
> > fs.Write(buf, 0, buf.Length);
> > fs.Close();
> >
> > "Me" <(E-Mail Removed)> wrote in message
> > news:Brt3c.33381$(E-Mail Removed)...
> > > Thanks Lloyd.
> > >
> > > Can you recommend where I can get any such code samples in vb.net?
> > >
> > >
> > > Thanks,
> > >
> > > Gigi
> > >
> > > "Lloyd Dupont" <net.galador@ld> wrote in message
> > > news:(E-Mail Removed)...
> > > > I suggest you save the ResposeStream content in a byte[]
> > > > and
> > > > 1. create a bitmap from these byte[](s)
> > > > 2. save this byte[](s) in a file
> > > >
> > > > "Me" <(E-Mail Removed)> wrote in message
> > > > news:JEs3c.56934$(E-Mail Removed)...
> > > > > I downloaded a JPG stream from a URI using a WebRequest
> > > > >
> > > > > Request = WebRequest.Create(http://myWebpage.jpg)
> > > > > Response = Request.GetResponse
> > > > > ResponseStream = Response.GetResponseStream
> > > > >
> > > > > I then convert the response to a bitmap file
> > > > > PictureBox1.Image = New Bitmap(ResponseStream)
> > > > >
> > > > > What I would like to do now is to to save the file to the PDA?
> > > > >
> > > > > Is there any straightforward, easy way to do this in CF?
> > > > >
> > > > > Thanks,
> > > > >
> > > > > Gigi
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Me
Guest
Posts: n/a
 
      13th Mar 2004
Muhammad,

Thanks for your response. I may have to try this.


Best regards,

Gigi
"Muhammad Arif" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Visit the following URL
> http://www.opennetcf.org/Forums/topic.asp?TOPIC_ID=385
>
> Regards,
> Arif
>
>
> "Me" <(E-Mail Removed)> wrote in message

news:<JEs3c.56934$(E-Mail Removed)>...
> > I downloaded a JPG stream from a URI using a WebRequest
> >
> > Request = WebRequest.Create(http://myWebpage.jpg)
> > Response = Request.GetResponse
> > ResponseStream = Response.GetResponseStream
> >
> > I then convert the response to a bitmap file
> > PictureBox1.Image = New Bitmap(ResponseStream)
> >
> > What I would like to do now is to to save the file to the PDA?
> >
> > Is there any straightforward, easy way to do this in CF?
> >
> > Thanks,
> >
> > Gigi



 
Reply With Quote
 
Me
Guest
Posts: n/a
 
      14th Mar 2004
I thank you for your responses! After some careful inspection of my code, I
finally sorted out the problem. Here is the working code:

Dim Response As WebResponse
Dim ResponseStream As Stream
Dim Request As WebRequest


Request = WebRequest.Create("http://www.images.image.jpg")
Response = Request.GetResponse
ResponseStream = Response.GetResponseStream


Dim numBytesToRead As Integer = CInt(Response.ContentLength)

Dim bytes(Response.ContentLength) As Byte
Dim numBytesRead As Integer = 0
While numBytesToRead + 1 > 0
Dim n As Integer = ResponseStream.Read(bytes, numBytesRead,
numBytesToRead)
' The end of the file has been reached.
If n = 0 Then
Exit While
End If
numBytesRead += n
numBytesToRead -= n
End While

'Cursor.Current = Cursors.Default
'Response.Close()


Dim b As Bitmap
b = New Bitmap(New MemoryStream(bytes))

Dim fs As New FileStream("myfileB.jpeg", FileMode.Create)

fs.Write(bytes, 0, bytes.Length)

fs.Close()

Cursor.Current = Cursors.Default
Response.Close()

Dim myBitmap As Bitmap
myBitmap = New Bitmap("myfileB.jpeg")

PictureBox1.Image = myBitmap
PictureBox1.Update()

Gigi

"Me" <(E-Mail Removed)> wrote in message
news:JEs3c.56934$(E-Mail Removed)...
> I downloaded a JPG stream from a URI using a WebRequest
>
> Request = WebRequest.Create(http://myWebpage.jpg)
> Response = Request.GetResponse
> ResponseStream = Response.GetResponseStream
>
> I then convert the response to a bitmap file
> PictureBox1.Image = New Bitmap(ResponseStream)
>
> What I would like to do now is to to save the file to the PDA?
>
> Is there any straightforward, easy way to do this in CF?
>
> Thanks,
>
> Gigi
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
getting the File System Object to run File Save As instead of just File Save Paul Microsoft Access Form Coding 2 18th Oct 2009 08:11 AM
Excel file becomes corupted when using Save As to save file. =?Utf-8?B?cmJvd2Rlbg==?= Microsoft Excel Crashes 0 11th Oct 2004 08:11 PM
Excel marcos firing on file save as but not file save Andy Microsoft Excel Programming 1 3rd Aug 2004 10:34 AM
Save File to Another Directory, but not change Users File Save location Mike Knight Microsoft Excel Programming 1 28th May 2004 09:06 PM
Paint cannot save this fle. Save was interrupted, so your file has not been save Stephen Bishop Microsoft Windows 2000 1 1st Aug 2003 05:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:14 AM.