469,580 Members | 1,910 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,580 developers. It's quick & easy.

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 3058
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Tom | last post: by
2 posts views Thread by Vladislav Moltchanov | last post: by
13 posts views Thread by Siegfried Heintze | last post: by
5 posts views Thread by coinjo | last post: by
2 posts views Thread by Michael | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.