473,378 Members | 1,162 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,378 software developers and data experts.

Saving files locally downloaded from the net

Hi,
I am downloading data from the Internet using the following lines.

networkStream = tcpClient.GetStream(); // tcpClient specifies port +
ip
StreamReader streamReader = new StreamReader(networkStream);
response = streamReader.ReadLine();

After doing correct parsing of the downloaded code, I identify the
file extension such as txt, jpg, mp3, etc.

Now I would like to write the file locally, by creating the file and
storing the data retrieved. To write to the file I am using the
following.

StreamWriter streamWriter = new StreamWriter(path, false);
streamWriter.Writeline(data);

This technique has worked for text documents but is failing in other
files.

Can someone provide some help.
Thanks in Advance
Nov 16 '05 #1
1 1107
Hi Xarky,

I believe the problem may be caused by reading single lines which doesn't
make sense for non text data.
I would use StreamReader.ReadToEnd, WebClient.DownloadFile or handle the
Stream directly and reading chunks of bytes.

--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: | last post by:
Although this question does not belong in here, I hope someone help, as I do not know where to send it, but someone here might have come acros similar problem: Some of JPG files sitting in the...
1
by: Mark Richards | last post by:
Assume I have downloaded a couple of related html web pages with (locally transformed) links between them. Now I want to put all these html source files into ONE *.pdf or *.chm file. All the links...
8
by: Mike Smith | last post by:
If I put an old exe file on a web site and create a link to it then IE will ask "open or save to disk?" when clicked. When I create an exe with VS.NET it does not ask anything, it just tries to...
3
by: Dennis Kuhn | last post by:
Years ago I downloaded a series of files from Microsoft with lots of practical suggestions for Access97 (which I'm still using at work). The filenames are: FrmSmp97 (Form ideas) Grphsm97...
1
by: bruce.1 | last post by:
I'm trying to figure a way for a remote user -- using ASP.NET -- to share files on a local office LAN. The remote user would go to an ASP.NET website (on the LAN), mark the files they want, and...
4
by: André Wagner | last post by:
Hello, I'm writing a HTML/javascript application who will run locally. I want to save to a local file. If I were using IE, I would do this way: var fso = new...
4
by: Pedro Leite | last post by:
Good Afternoon. the code below is properly retreiving binary data from a database and saving it. but instead of saving at client machine is saving at the server machine. what is wrong with my...
1
by: harriegovin | last post by:
Hi, Here is the scenario. I have a web application written in vb.net. One of the functionalities of the application is to save the recordset in an xml format on to the client machine. The xml...
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.