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

Help: Saving HTML file using C# in Win app or Win service

I need to generate HTML files based on the some codes. One HTML file per
code. I have the link
(ex:http://123.234.345.456/WebPages/GetT...x?SomeCode=25), by passing
the code as parameter I will get the page displayed.

But I don't want to display it, instead save those files in one of the
network directories that can be accessed by our third party vended web based
application. How can I do this accessing and saving HTML files a directory
using C# in a windows app or Windows service? Any help?

Thanks in advance for your time and help,
Vijay
Nov 2 '05 #1
6 3252
Is it that much difficult to provide solution? Is it the same for MSFTs too?
Please provide some workable solution I have an urgent need.

Thanks,
Vijay
"Vijay" wrote:
I need to generate HTML files based on the some codes. One HTML file per
code. I have the link
(ex:http://123.234.345.456/WebPages/GetT...x?SomeCode=25), by passing
the code as parameter I will get the page displayed.

But I don't want to display it, instead save those files in one of the
network directories that can be accessed by our third party vended web based
application. How can I do this accessing and saving HTML files a directory
using C# in a windows app or Windows service? Any help?

Thanks in advance for your time and help,
Vijay

Nov 3 '05 #2

HTML files are just text files.

You can just use a StreamWriter for saving the HTML string to a file.

Vijay wrote:
Is it that much difficult to provide solution? Is it the same for MSFTs too?
Please provide some workable solution I have an urgent need.

Thanks,
Vijay
"Vijay" wrote:

I need to generate HTML files based on the some codes. One HTML file per
code. I have the link
(ex:http://123.234.345.456/WebPages/GetT...x?SomeCode=25), by passing
the code as parameter I will get the page displayed.

But I don't want to display it, instead save those files in one of the
network directories that can be accessed by our third party vended web based
application. How can I do this accessing and saving HTML files a directory
using C# in a windows app or Windows service? Any help?

Thanks in advance for your time and help,
Vijay

Nov 3 '05 #3
But I need to somehow load the webpage using some control and get the HTML
source code and write (save) to the disk. Here is what I did:

My code does not seem to be working. Please take a look at it and provide
where I need to change. My debugger is coming to the first line of the
DocumentComplete event and that is it. It is not going to the second line nor
giving me any exception.

object oPage = "http://www.google.com";
axWebBrowser1.Navigate2(ref oPage);

' Event
private void axWebBrowser1_DocumentComplete(object sender,
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
UCOMIPersistFile oPersistFile = (UCOMIPersistFile)e.pDisp;
string xx = @"C:\MyWebPage.html";
oPersistFile.Save(xx, true);
}

Thanks,
Vijay
-------------------------------------------------------------------------------------------

"John A. Bailo" wrote:

HTML files are just text files.

You can just use a StreamWriter for saving the HTML string to a file.

Vijay wrote:
Is it that much difficult to provide solution? Is it the same for MSFTs too?
Please provide some workable solution I have an urgent need.

Thanks,
Vijay
"Vijay" wrote:

I need to generate HTML files based on the some codes. One HTML file per
code. I have the link
(ex:http://123.234.345.456/WebPages/GetT...x?SomeCode=25), by passing
the code as parameter I will get the page displayed.

But I don't want to display it, instead save those files in one of the
network directories that can be accessed by our third party vended web based
application. How can I do this accessing and saving HTML files a directory
using C# in a windows app or Windows service? Any help?

Thanks in advance for your time and help,
Vijay

Nov 4 '05 #4
Solution:
----------

private void button1_Click(object sender, System.EventArgs e)
{
string sURL = "www.google.com";
axWebBrowser1.Navigate(sURL);
}

// axWebBrowser1 event
private void axWebBrowser1_DocumentComplete(object sender,
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)

{

string sFileName = System.Windows.Forms.Application.StartupPath +
"\\ATC.htm";

UCOMIPersistFile oPersistFile =
(UCOMIPersistFile)axWebBrowser1.Document;

oPersistFile.Save(sFileName, true);

}
"Vijay" wrote:
But I need to somehow load the webpage using some control and get the HTML
source code and write (save) to the disk. Here is what I did:

My code does not seem to be working. Please take a look at it and provide
where I need to change. My debugger is coming to the first line of the
DocumentComplete event and that is it. It is not going to the second line nor
giving me any exception.

object oPage = "http://www.google.com";
axWebBrowser1.Navigate2(ref oPage);

' Event
private void axWebBrowser1_DocumentComplete(object sender,
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
UCOMIPersistFile oPersistFile = (UCOMIPersistFile)e.pDisp;
string xx = @"C:\MyWebPage.html";
oPersistFile.Save(xx, true);
}

Thanks,
Vijay
-------------------------------------------------------------------------------------------

"John A. Bailo" wrote:

HTML files are just text files.

You can just use a StreamWriter for saving the HTML string to a file.

Vijay wrote:
Is it that much difficult to provide solution? Is it the same for MSFTs too?
Please provide some workable solution I have an urgent need.

Thanks,
Vijay
"Vijay" wrote:
>I need to generate HTML files based on the some codes. One HTML file per
>code. I have the link
>(ex:http://123.234.345.456/WebPages/GetT...x?SomeCode=25), by passing
>the code as parameter I will get the page displayed.
>
>But I don't want to display it, instead save those files in one of the
>network directories that can be accessed by our third party vended web based
>application. How can I do this accessing and saving HTML files a directory
>using C# in a windows app or Windows service? Any help?
>
>Thanks in advance for your time and help,
>Vijay

Nov 7 '05 #5

It that correct because even though it works, you are going outside the
scope of the event to get the Document property.

This wouldn't work write, if say, you threaded the thing and raised
multiple events simultaneously.

Every time the out of scope axWebBrowser1 object changed, you would be
changing the .Document property.
Vijay wrote:
Solution:
----------

private void button1_Click(object sender, System.EventArgs e)
{
string sURL = "www.google.com";
axWebBrowser1.Navigate(sURL);
}

// axWebBrowser1 event
private void axWebBrowser1_DocumentComplete(object sender,
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)

{

string sFileName = System.Windows.Forms.Application.StartupPath +
"\\ATC.htm";

UCOMIPersistFile oPersistFile =
(UCOMIPersistFile)axWebBrowser1.Document;

oPersistFile.Save(sFileName, true);

}
"Vijay" wrote:

But I need to somehow load the webpage using some control and get the HTML
source code and write (save) to the disk. Here is what I did:

My code does not seem to be working. Please take a look at it and provide
where I need to change. My debugger is coming to the first line of the
DocumentComplete event and that is it. It is not going to the second line nor
giving me any exception.

object oPage = "http://www.google.com";
axWebBrowser1.Navigate2(ref oPage);

' Event
private void axWebBrowser1_DocumentComplete(object sender,
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEve nt e)
{
UCOMIPersistFile oPersistFile = (UCOMIPersistFile)e.pDisp;
string xx = @"C:\MyWebPage.html";
oPersistFile.Save(xx, true);
}

Thanks,
Vijay
-------------------------------------------------------------------------------------------

"John A. Bailo" wrote:

HTML files are just text files.

You can just use a StreamWriter for saving the HTML string to a file.

Vijay wrote:

Is it that much difficult to provide solution? Is it the same for MSFTs too?
Please provide some workable solution I have an urgent need.

Thanks,
Vijay
"Vijay" wrote:

>I need to generate HTML files based on the some codes. One HTML file per
>code. I have the link
>(ex:http://123.234.345.456/WebPages/GetT...x?SomeCode=25), by passing
>the code as parameter I will get the page displayed.
>
>But I don't want to display it, instead save those files in one of the
>network directories that can be accessed by our third party vended web based
>application. How can I do this accessing and saving HTML files a directory
>using C# in a windows app or Windows service? Any help?
>
>Thanks in advance for your time and help,
>Vijay

Nov 8 '05 #6
I guess it all depends on the requirement. The requirement I have is simple,
all I need to do is to wait till the document loaded (Async event). You might
be right in complex scenario.

But do you know how you can do it without form and placing the control on
the form. I guess Microsoft did not come up with such a thing, in the Browser
control, that just load into memory without displaying the page and get the
stream from the object. I don't know whether this is true in their new
release VS 2005. I guess, this scenario is really useful in Windows Service.
"John A. Bailo" wrote:

It that correct because even though it works, you are going outside the
scope of the event to get the Document property.

This wouldn't work write, if say, you threaded the thing and raised
multiple events simultaneously.

Every time the out of scope axWebBrowser1 object changed, you would be
changing the .Document property.
Vijay wrote:
Solution:
----------

private void button1_Click(object sender, System.EventArgs e)
{
string sURL = "www.google.com";
axWebBrowser1.Navigate(sURL);
}

// axWebBrowser1 event
private void axWebBrowser1_DocumentComplete(object sender,
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)

{

string sFileName = System.Windows.Forms.Application.StartupPath +
"\\ATC.htm";

UCOMIPersistFile oPersistFile =
(UCOMIPersistFile)axWebBrowser1.Document;

oPersistFile.Save(sFileName, true);

}
"Vijay" wrote:

But I need to somehow load the webpage using some control and get the HTML
source code and write (save) to the disk. Here is what I did:

My code does not seem to be working. Please take a look at it and provide
where I need to change. My debugger is coming to the first line of the
DocumentComplete event and that is it. It is not going to the second line nor
giving me any exception.

object oPage = "http://www.google.com";
axWebBrowser1.Navigate2(ref oPage);

' Event
private void axWebBrowser1_DocumentComplete(object sender,
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEve nt e)
{
UCOMIPersistFile oPersistFile = (UCOMIPersistFile)e.pDisp;
string xx = @"C:\MyWebPage.html";
oPersistFile.Save(xx, true);
}

Thanks,
Vijay
-------------------------------------------------------------------------------------------

"John A. Bailo" wrote:
HTML files are just text files.

You can just use a StreamWriter for saving the HTML string to a file.

Vijay wrote:

>Is it that much difficult to provide solution? Is it the same for MSFTs too?
>Please provide some workable solution I have an urgent need.
>
>Thanks,
>Vijay
>
>
>"Vijay" wrote:
>
>
>
>>I need to generate HTML files based on the some codes. One HTML file per
>>code. I have the link
>>(ex:http://123.234.345.456/WebPages/GetT...x?SomeCode=25), by passing
>>the code as parameter I will get the page displayed.
>>
>>But I don't want to display it, instead save those files in one of the
>>network directories that can be accessed by our third party vended web based
>>application. How can I do this accessing and saving HTML files a directory
>>using C# in a windows app or Windows service? Any help?
>>
>>Thanks in advance for your time and help,
>>Vijay

Nov 8 '05 #7

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

Similar topics

2
by: Tom | last post by:
OK I'm trying to go to the end of a file and delete the contents upwards until I meet a certain character. How can I do this? (NOTE: I'm using text files)
2
by: Vladislav Moltchanov | last post by:
Recently I have changed from Acc97 to Acc2000 (I had to supply some data entry tools for field data collection for users still using Acc97). Among lot of other complications coming with Acc2000...
13
by: Siegfried Heintze | last post by:
I refered the engineer at my hosting service to http://support.microsoft.com/default.aspx?scid=kb;en-us;825738 where he tried to follow the directions there. He said there was no such file:...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
0
by: David Hearn | last post by:
I have created a web service that will be running on one of our servers. It has a function in it called UploadFile. The way we would like to use it is the user types in the url...
6
by: Vijay | last post by:
I need to generate HTML files based on the some codes. One HTML file per code. I have the link (ex:http://123.234.345.456/WebPages/GetTestData.aspx?SomeCode=25), by passing the code as parameter I...
5
by: coinjo | last post by:
Problem Statement One of the local banks is gearing up for a big advertising campaign and would like to see how long its customers are waiting for service by teller/service provider at drive-up...
2
by: Michael | last post by:
We have an ASP.NET 2.0 web application running on a Windows 2003 domain controller. Part of that application needs to read and write files from and to a network share ( living on a MAC Xserveraid)...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: 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...
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...

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.