Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I want to develop an application which reads a file from the server and gives popup window like many antivirus programs give in the right corner at system startup.
I need to know:
What should I study for that?
Is only file IO enough to do this?

The file can be in txt formate which need to be read.

Thanks
Posted
Updated 8-Nov-10 21:44pm
v2

1 solution

hello;
for reading a file you can use normal system.IO functions for file streaming using C# windows application, but it depends where is your server how you are connected to it and how you want to access your file , by HTTP ?? or remote SQL reading from database??
just explain more what are you thinking about and what are your exact aims and We will help you in coding ...
regards...

how to download files using HTTP by passing Proxy server. This article explains how to pass proxy server network credentials when downloading files using HTTP.
Passing Network Credentials
If your company is using proxy server to connect to the Internet, you will have to pass proxy settings to download files from the Internet using HTTP. To do so, you need to create a WebProxy instance, and set its Credentials property, which is NetworkCredential and takes userId, password, and network domain.
Here is the code that uses network credentials:
string result = "";
try
{
WebProxy proxy = new WebProxy("http://proxy:80/", true);
proxy.Credentials = new NetworkCredential("userId", "password", "Domain"); 
WebRequest request = WebRequest.Create(http://www.c-sharpcorner.com);
request.Proxy = proxy;
// Send the 'HttpWebRequest' and wait for response. 
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); System.IO.Stream stream = response.GetResponseStream();
System.Text.Encoding ec = System.Text.Encoding.GetEncoding("utf-8");
System.IO.StreamReader reader = new System.IO.StreamReader(stream, ec);
char [] chars = new Char[256];
int count = reader.Read(chars, 0, 256);
while(count > 0)
{
string str = new String(chars, 0, 256);
result = result + str;
count = reader.Read(chars, 0, 256);
}
response.Close();
stream.Close();
reader.Close();
}
catch(Exception exp)
{
string str = exp.Message;
}

Using HTTPS with WebProxy Class
When you create a WebProxy class instance for a proxy server to pass proxy to download files from the Internet using HTTP, code looks like this:
WebProxy proxy = new WebProxy("http://proxy:80/", true);
However, this code will not work when you want to download a file from HTTPS. You need to use the following code to create a WebProxy instance for HTTPS:
WebProxy myProxy = new WebProxy("server.https.com", 443);


hope that helps you .. regards..
 
Share this answer
 
v2
Comments
Bhavin Jagad 9-Nov-10 4:31am    
i need to read from http.
actually whatever updates are done on the web page is written in the text file.

i just need to read that file and prompt "xyz is updated" on my computer on start up.

can it be done throw following way??

// First, create a WebRequest to a URI.
HttpWebRequest req = (HttpWebRequest)
WebRequest.Create("http://www.mywebaddress.com");
// Next, send that request and return the response.
HttpWebResponse resp = (HttpWebResponse)
req.GetResponse();
// From the response, obtain an input stream.
Stream istrm = resp.GetResponseStream();

can i use ip instead of the site name??

thank you
Tamer Hatoum 9-Nov-10 7:18am    
Please I have updated my post ...
regards..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900