By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,025 Members | 2,118 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,025 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a

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

P: n/a
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

P: n/a
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

P: n/a

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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.