Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

For a simple, single page 'save as' you could start with something like this (adapted from an example posted by Robby in this thread):

 

Dim sHtml As String
Dim sr As IO.StreamReader
Dim wc As New Net.WebClient()

sr = New IO.StreamReader(wc.OpenRead(m_URL))
sHtml = sr.ReadToEnd
sr.DiscardBufferedData()
sr.Close()
wc.Dispose()

 

The code above reads an html file into a string (sHtml) - which you could then write to a file of your choice (or a user's selecting) with standard file I/O.

 

If you wanted to mimic the 'save complete' functionality of the IE 'save as' you'd need to do a bit more work (or somehow tap into IE to do it for you). You'd need to parse the main html file to find all linked resources like images, css files, script files, etc and do similar saves for each one of them seperately.

 

Paul

Posted

That should get me started. Maybe I'll just save the string to a file and search it for things like, .gif,.jpg,.png,.swf, etc. and then pull those down that way.

 

I was just thinking also, if anyone knows how to programatically get the names of all the files/folders in a directory, that may be helpfull to me as well.

 

Thanks for you help!

 

 

 

For a simple' date=' single page 'save as' you could start with something like this (adapted from an example posted by Robby in this thread):

 

Dim sHtml As String
Dim sr As IO.StreamReader
Dim wc As New Net.WebClient()

sr = New IO.StreamReader(wc.OpenRead(m_URL))
sHtml = sr.ReadToEnd
sr.DiscardBufferedData()
sr.Close()
wc.Dispose()

 

The code above reads an html file into a string (sHtml) - which you could then write to a file of your choice (or a user's selecting) with standard file I/O.

 

If you wanted to mimic the 'save complete' functionality of the IE 'save as' you'd need to do a bit more work (or somehow tap into IE to do it for you). You'd need to parse the main html file to find all linked resources like images, css files, script files, etc and do similar saves for each one of them seperately.

 

Paul

Posted

I was just thinking also, if anyone knows how to programatically get the names of all the files/folders in a directory, that may be helpfull to me as well.

[msdn=System.IO.Directory]Directory Class[/msdn]

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Posted
Sorry, I think I should have been more specific. When I said I wanted to "programatically get the names of all the files/folders in a directory", I should have stated that I meant on an http site. Something like this: Dir http://www.yahoo.com/*.* and that would give me all the files and folders in the root dir of yahoo.com... Would the directory class you suggested be able to do something like that? Thanks for your help.
  • 4 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...