473,395 Members | 1,466 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,395 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 3254
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...
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...
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...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.