473,387 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 1631
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: gb | last post by:
hi, i placed System.Windows.Forms.WebBrowser in my WinForm. When i tried loading word document, it opens the File Download window. My question is how can i avoid the File Download window from...
1
by: theburnetts | last post by:
I am building an ASP.NET application that has a requirement that the user should be able to download all of the data that they have input into the system and save it to a file on their local PC. ...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
0
by: ichi32 | last post by:
Hello, I want to know how to use the System.Net.WebClient in my application. Here is the part of the code: System.Net.WebClient client = new System.Net.WebClient(); ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.