471,348 Members | 1,428 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 software developers and data experts.

Download file to local file system

I am working on a player application for my podcast, currently all it
does is make a Windows Media Player control open the MP3 file you select
from a listbox populated by the RSS feed. I am trying to add a 'save'
feature that downloads the MP3 to the local file system, but everything
I have tried has resulted in corrupt files. Can anyone help?
Jan 12 '06 #1
5 1568
Stefan,

Can you show your code, what you have already? It would help serve as a
base.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Stefan Nuxoll" <ne******@gmail.com> wrote in message
news:11*************@corp.supernews.com...
I am working on a player application for my podcast, currently all it does
is make a Windows Media Player control open the MP3 file you select from a
listbox populated by the RSS feed. I am trying to add a 'save' feature
that downloads the MP3 to the local file system, but everything I have
tried has resulted in corrupt files. Can anyone help?

Jan 12 '06 #2
Nicholas Paldino [.NET/C# MVP] wrote:
Stefan,

Can you show your code, what you have already? It would help serve as a
base.

I kind of deleted all of my code in anger, but basically it opened a
save dialog, instanced a webclient, read the file line by line and
copied it into a stream at the location the user choose in the save
dialog. I am guessing reading the file in the fashion I am doing is the
issue?
Jan 12 '06 #3
Yep, since it's a binary file you want to read and write the file in
bytes instead of line by line. Otherwise it will read in "lines" that
may or may not exist, and when it's writing those lines it will remove
whatever character it deems is a line break and replace it with the
current environment's line break thus corrupting the file.

--
Benny Raymond
http://bloatedcowsoftware.com

Stefan Nuxoll wrote:
Nicholas Paldino [.NET/C# MVP] wrote:
Stefan,

Can you show your code, what you have already? It would help
serve as a base.

I kind of deleted all of my code in anger, but basically it opened a
save dialog, instanced a webclient, read the file line by line and
copied it into a stream at the location the user choose in the save
dialog. I am guessing reading the file in the fashion I am doing is the
issue?

Jan 12 '06 #4
How would you suggest doing this than, do I still have to go the stream
approach or is there some magic, copy from URL to local filesystem
command?

Jan 12 '06 #5
This should do it:

WebClient Client = new WebClient();

try

{

Client.DownloadFile(RemoteFileUrl, LocalFileName);

}

"Stefan Nuxoll" <ne******@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
How would you suggest doing this than, do I still have to go the stream
approach or is there some magic, copy from URL to local filesystem
command?

Jan 13 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by gb | last post: by
1 post views Thread by theburnetts | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.