Why the files my program create are created twice each file double ? And why sometimes the files size are too small ?

My program is using Queue of type Uri to create Queue of urls and then i'm using webbrowser to navigate each Uri from the Queue in it's turn and get the url(html) source content and save it to the hard disk.
The problem is sometimes the text files on the hard disk are small like 90KB or 60KB and sometimes they are as they are suppose to be 300KB or 200KB.
This is a button click event where i'm calling two methods:
private void toolStripButton3_Click(object sender, EventArgs e)
GetHtmls();
CheckQueue();
This is the GetHtmls method code:
private Queue<Uri> myUrls = new Queue<Uri>();
private bool isBusy = false;
private void GetHtmls()
for (int i = 1; i < 49; i++)
adrBarTextBox.Text = sourceUrl + i;
targetHtmls = (combinedHtmlsDir + "\\Html" + i + ".txt");
Uri targetUri = new Uri(sourceUrl + i);
myUrls.Enqueue(targetUri);
sourceUrl contain website address: http://www.tapuz.co.il/forums2008/forumpage.aspx?forumid=393&pagenumber=
And i'm adding to it the numbers and create the pages.
And add them to the Queue.
THen the CheckQueue method:
Uri uri;
private void CheckQueue()
if (isBusy)
return; // We're downloading some page right now, don't disturb
isBusy = true; // OK, let's get started
if (myUrls.Count == 0) // No more pages to download, we're done
isBusy = false;
return;
uri = myUrls.Dequeue(); // Get one URL from queue
getCurrentBrowser().Navigate(uri);
It suppose to Navigate to each Uri(html address) in the Queue.
And the browser document completed event:
private void Form1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
// If page loaded completly then do something
int urlnumber = uri.ToString().IndexOf("pagenumber=");
string number = uri.ToString().Substring(urlnumber + 11);
int num = Int32.Parse(number);
targetHtmls = (combinedHtmlsDir + "\\Html" + num + ".txt");
StreamWriter writer = File.CreateText(targetHtmls);
writer.Write(getCurrentBrowser().DocumentText);
writer.Close();
isBusy = false; // We're done
CheckQueue(); // Check next page in queue
In the completed event i'm getting the page number and build the string for the text file then write the html source content to the text file.
In the end i have on my hard disk 48 text files.
The problems are:
1. Sometimes it seems like it's not finishing navigating to the current uri or maybe some other reason maybe server side problem and creating small size files with source content inside but not all the source content. Sometimes the text files size are each
file 99KB or 70KB and sometimes the size of them are about 300KB and 200KB and this is the right sizes 300KB 200KB.
2. The text files on my hard disk suppose to be 48 different files each file should contain the source if the html page of the 48 pages. But on my hard disk the 48 text files are duplicated for some reason.
This is the file on my hard disk:
Some of the files are 205KB 350KB 175KB and some of the files sizes are 85KB 94KB 35KB 
Why some of the files it didn't navigated to the end or maybe didn't got all the source ?
And why it's making each second file the same like the one before ? It suppose to create 48 different files but i'm getting two identical files each navigation.

I solved it now.
This is what i did:
It's a bit slow process since i'm waiting for each page to be loaded into the webbrowser but it does the work.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections;
using System.IO;
using System.Net;
namespace WindowsFormsApplication1
public partial class Form1 : Form
private string sourceUrl = "http://test.test";
private string htmlsTargetDirectory = "Test Htmls";
private string appDir = Path.GetDirectoryName(@"C:\Users\chocolade1972\AppData\Local\Test_Images\Test Images\Test Htmls");
private string combinedHtmlsDir;
private String targetHtmls;
private int counter = 1;
private StreamWriter w;
private string uri;
private bool htmlloaded = false;
public Form1()
InitializeComponent();
webBrowser1.ScriptErrorsSuppressed = true;
combinedHtmlsDir = Path.Combine(appDir, htmlsTargetDirectory);
if (!Directory.Exists(combinedHtmlsDir))
Directory.CreateDirectory(combinedHtmlsDir);
private void Form1_Load(object sender, EventArgs e)
GetHtmls();
timer1.Enabled = true;
private void GetHtmls()
uri = sourceUrl + counter;
targetHtmls = (combinedHtmlsDir + "\\Html" + counter + ".txt");
webBrowser1.Navigate(uri);
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
if (e.Url.ToString() == uri)
targetHtmls = (combinedHtmlsDir + "\\Html" + counter + ".txt");
htmlloaded = true;
StreamWriter writer = File.CreateText(targetHtmls);
writer.Write(webBrowser1.DocumentText);
writer.Close();
FileInfo fi = new FileInfo(targetHtmls);
var size = fi.Length;
w = new StreamWriter(combinedHtmlsDir + "\\test.txt", true);
w.WriteLine("File Size " + size);
w.Close();
private void timer1_Tick(object sender, EventArgs e)
if (htmlloaded == true)
uri = sourceUrl + counter;
myurls.Add(uri);
webBrowser1.Navigate(uri);
htmlloaded = false;
counter += 1;

Similar Messages

  • Created a movie in IMOVIE and transferred it to dvd but cannot get it to play on my dvd player.  i downloaded the free Burn program since i don't have idvd on my new mac  the dvd comes up disk error or cannot read

    created a movie in IMOVIE and transferred it to dvd but cannot get it to play on my dvd player.  i downloaded the free Burn program since i don't have idvd on my new mac  the dvd comes up disk error or cannot read.  I am using a dvd-r dvd and my dvd player says that it uses this type of dvd.  Any suggestions.  I spoke to an Apple Support person who helped me burn the dvd but it still didn't work...help???

    There's a difference between a data DVD, and a DVD-Video.  I believe you made a data DVD, which can't be played in a video player.  The Burn feature of the Finder can't author a DVD-V, just data discs.   
    I assume you made a Project, and put clips from your Event Library into the Project.  But then, how did you output your Project, using the SHARE menu? 
    When I pull down iMovie '11s SHARE menu, "iDVD..." is one of the options.  It's the job of iDVD to make the menu that appears when you insert a DVD into your player (that says the title, and chapters, and extras, etc.).  You need software that will made a DVD-V disc.  Lacking that, you might be able to go to Share/Export Movie... or Share/Export using QuickTime... to get your video into a format that software like Roxio's Toast could burn. 

  • I am trying to create a simple animated gif in Photoshop. I've set up my frames and want to use the tween to make the transitions less jerky. When I tween between frame 1 and frame 2 the object in frame two goes out of position, appearing in a different p

    I am trying to create a simple animated gif in Photoshop. I've set up my frames and want to use the tween to make the transitions less jerky. When I tween between frame 1 and frame 2 the object in frame two goes out of position, appearing in a different place than where it is on frame 2. Confused!

    Hi Melissa - thanks for your interest. Here's the first frame, the second frame and the tween frame. I don't understand why the tween is changing the position of the object in frame 2, was expecting it to just fade from one frame to the next.

  • HT2513 I have a mac and an ipad.  when i create and ical event on my mac and then sync to my ipad, the event replicates;   however, when i create an ical event on my ipad and then sync, the ical event does not sync.

    Question:  I have a mac and an ipad.  when i create an ical event on my mac and then sync, the event transfers to my ipad. HOWEVER: when i create an ical event on my ipad and then sync, the event does not transfer.  what am i doing wrong???
    cadybill

    Greetings,
    Go to Apple > Software Update and install all available updates until no more are offered.
    On iPad go to Settings > General > Software Update and install any updates.
    Follow this article for issues with calendars: http://support.apple.com/kb/TS2481
    Hope that helps.

  • What is the best software programs that I can use to read, write and modify data / files on external HD (NTFS format i.e.  Windows) ?

    Hi guys,
    I’m new to Mac and have a MacBook Pro Lion OS (10.6.8 I think !!!) with Parallels 7 (Windows 7) installed. Can someone please tell me what is the best software program that I can use to read, write and modify data / files on external HD (NTFS format) from the Mac OS ? I heard of Paragon and Tuxera NTFS. Are they free ? Are they good ? Are there any other software programs out there ? I heard that some people have issues with Paragon.
    Thanks.

    Your best bet would be to take the drive to the oldest/compatible with that drive Windows PC and grab the files off, right click and format it exFAT (XP users can download exFAT from Microsoft) and then put the files back on.
    Mac's can read and write all Windows files formats except write to NTFS (and in some cases not read) so if you can change the format of the drive to exFAT (all data has to be remove first) then you will have a drive that doesn't require paid third party NTFS software (a license fee goes to Microsoft) for updates.
    Also it's one less hassle to deal with too.
    .Drives, partitions, formatting w/Mac's + PC's

  • I am creating a slideshow with elements using photos and videos but the video sound doesnt play?

    I am creating a slideshow with elements using photos and videos but the video sound doesnt play?

     Hello jive
         I am playing it back in the slideshow editor/setting up part of
    programme where you determine photos/video to be included gaps between
    slides, music to play etc This goes through each phot and when comes
    to a video the background sound doesnt play, I am using windows 7 and
    elements 10.
         regards gins51

  • The latest changes to the function to "Upload to FTP host" has rendered this useless - no point using a program like Muse if I can not easily and automatically upload the work to the webserver!

    The latest changes to the function to "Upload to FTP Host" has rendered this useless - no point using a program like Muse if I can not easily and automatically upload the work to the webserver!  I use BlueHost webhosting that has a primary domain and I have several domains with that account (as sub-domains or folders on this server) - with past versions of Muse when uploading pages it simply opened an alert window to tell me (what I already know) that the website I was uploading does not point to the primary domain BUT NOW Muse tries to create a new separate folder in the root directory of the primary domain - completely ignoring the directory path I am giving it - useless!  Why make these senseless changes to the program - and so often - very frustrating it is like amateur ware!.

    Hi Stephen,
    There are some issues with the upload to ftp via Muse, which the engineering team is aware of and those will be fixed in a future build of Muse. At this point the work around would be to export the html from Muse and then upload via some third party ftp client like filezilla.
    I will recommend that you keep an eye on our release notes page to get more updates on it - Release notes | Adobe Muse CC
    - Abhishek Maurya

  • AE what are those things that turns on and off in the Project

    AE what are those things that turns on and off in the Project

    I had was $1,000 credit in September of 2014.  In October, I called Digital Juice, because I had a stroke 25 years ago and I told him I would be foolish to give up $1,000 and join Platinum Account.  He agreed with me. He then said why don’t you join Platinum Account, and he can update the $1,000 to the account.  I said, OK.  Then about January 2, $1,000 was in the Platinum Account.  I am starting to do some Wedding videos, and I just noticed that the $1,000 credit wasn’t there. What happened to my $1,000?  Oh by the way, your Update Status only goes back to December and not back to July.
    Rich
    "Todd_Kopriva" <[email protected]> said:
    AE what are those things that turns on and off in the Project created by ( https://forums.adobe.com/people/Todd_Kopriva ) in After Effects - ( https://forums.adobe.com/message/7122815#7122815 )
    I don't understand the question. Please explain in more detail.

  • HT4796 How can I take the files that were migrated from my PC to my Mac and add all those files to my current user instead of having 2 users?

    How can I take the files that were migrated from my PC to my Mac and add all those files to my current user instead of having 2 users? Having to log out just to sign in on a different user to access the files is absurd.
    Do I make all the files sharable to all the NOW users on the mac then just delete the files? Or can i erase my account that I made when starting up my new mac and then just use the one with the transferred files?
    I just dont want to have to og in and out of 2 different accounts .. Help please.         
    -Nina

    Sorry. /Users is a folder path. It would be similar to C:\Users (if that exists on Windows).
    So, in the Finder, select Computer from the Go menu.
    You'll see Macintosh HD, double-click that to open it.
    In there you'll see several folders. One is Users. That is where all the user Home folders exist. Select the other account's home folder and go to step 3.
    If you have any more confusion, please stop and ask. We'll get there.
    If you feel more comfortable, you can just log into that other account and move the files into /Users/Shared.
    Then, log into the account you wish to use and copy the files from the Shared folder and paste them into your Home folder, wherever they belong, Documents, Music, Pictures, etc.  That just takes a little more work. Transferring them into Shared, and then copying into your home sets the permissions on the files so that you won't have a problem accessing them later. The steps I provided just prevent you from having to do the double move, since you are not going to use the old account once you are done.
    Quick unix shorthand. If someone gives you a file path that begins with a /, that means the root of the hard drive, ie Macintosh HD (if you haven't renamed it). The path separator in unix is /, not \.
    A path that starts with ~/ means your Home folder, the one inside /Users named with your account name.

  • Why would it state under the "more about this mac" that i already have10.8.3 and then in the app store say i need to "resume" do you know what i mean? is it possible i already did download mountain lion entirely once? I am confused and don't want it twice

    why would it state under the "more about this mac" that i already have10.8.3 and then in the app store say i need to "resume" do you know what i mean? is it possible i already did download mountain lion entirely once? I am confused and don't want it twice

    This is cause by the way the App Store checks to see if an application is installed on your system.
    Basically when an app is installed it is in the Applications folder and this is where the MAS looks for them. So it looks at your purchase history for the apps you bought and looks in the Applications folder to see if they are installed. If an app is in your purchase history but not in the Applications folder the MAS says you need to install it.
    For normal apps this works fine but the OS doesn;t install into the Applications folder. So the MAS sees you have Mountain Lion in your purchase history but it's not in the Applications folder and so it says you need to download it.
    Hopefully one of these days Apple wil fix this.
    regards

  • Received adobe photoshop elements 12/adobe premiere elements 12 when I purchased a MacBook Pro.   The macBook Pro does not have a DVD player it is sold separately.     To install the program can I download a free trial version and then use the serial numb

    Received adobe photoshop elements 12/adobe premiere elements 12 when I purchased a MacBook Pro.   The macBook Pro does not have a DVD player it is sold separately.     To install the program can I download a free trial version and then use the serial numbers from the set I received?

    yes, that's exactly what you should do,
    Downloads available:
    Suites and Programs:  CC | CS6 | CS5.5 | CS5 | CS4 | CS3
    Acrobat:  XI, X | 9,8 | 9 standard
    Premiere Elements:  12 | 11, 10 | 9, 8, 7
    Photoshop Elements:  12 | 11, 10 | 9,8,7
    Lightroom:  5 | 4 | 3
    Captivate:  7 | 6 | 5
    Contribute:  CS5 | CS4, CS3
    Download and installation help for Adobe links
    Download and installation help for Prodesigntools links are listed on most linked pages.  They are critical; especially steps 1, 2 and 3.  If you click a link that does not have those steps listed, open a second window using the Lightroom 3 link to see those 'Important Instructions'.

  • Messages are in to be delivered state and slows down the message processing

    Hello,
    Messages are in to be delivered state and slows down the message processing.
    this happenens in case of DB2 on some machine where the issue about high load on DB2  is caused by standard programming in SAP XI that executes a statement, where it uses the condition 'where 1<0' prio to the original  SQL statement configured in the channel configuration,
    Can you please help me out in solving this issue?
    Thanks,
    Soorya

    Status: TO_BE_DELIVERED
    Which means that the message was successfully delivered from Integration Server point of view and it states that the messages is initially handed over to the Messaging System.
    TO_BE_DELIVERED occurs while the message is put into the Messaging System receive queue.
    Solution:
    This is done via the Messaging System receive servlet:
    http://<Host>:<PORT>/MessagingSystem/receive/<CONNECTION>
    /<PROTOCOL>
    Only if this was executed successfully the Messaging System returns HTTP 200 to the Integration Server and the Status TO_BE_DELIVERED moves to DELIVERING
    1. Try logging into Sap GUI with two users: XIAPPLUSER & XIAFUSER
    to see if they are blocked
    2. We can check the messages:
    AdapterFramework
    com.sap.aii.adapterframework.serviceuser.language
    com.sap.aii.adapterframework.serviceuser.name = XIAFUSER
    com.sap.aii.adapterframework.serviceuser.pwd
    ApplicationSystem
    com.sap.aii.applicationsystem.serviceuser.language
    com.sap.aii.applicationsystem.serviceuser.name = XIAPPLUSER
    com.sap.aii.applicationsystem.serviceuser.pwd
    in the exchange profile to make sure the right passwords

  • While updating my apps, I lost my wi-fi connection.  I have since tried to update the apps several times...but none of them are updating.  Each time I try to update the apps, I enter my password, but then nothing happens.  Thank you - Chris

    While updating my apps, I lost my wi-fi connection.  I have since tried to update the apps several times...but none of them are updating.  Each time I try to update the apps, I enter my password, but then nothing happens.  Thank you - Chris

    Hold the power button and the home button down until the screen goes black and the apple logo appears. This will do a reset and you should be able to update your apps then.

  • I have Dreamweaver CS6.  Is it possible to upgrade to Dreamweaver CC?  If so, are there any fees involved? And what is the process?

    I have Dreamweaver CS6.  Is it possible to upgrade to Dreamweaver CC?  If so, are there any fees involved? And what is the process?

    Unfortunately, CS6 is the last version Adobe made available for purchase on perpetual license.  So there are no upgrades available except to join the Creative Cloud and pay monthly.
    As a Creative Suite user, you qualify for a substantial discount for the first year -- $29.95/month for Full Plan which affords access to all the software and other services.
    Creative Cloud pricing and membership plans | Adobe Creative Cloud
    Nancy O.

  • Why are apple cords/chargers so cheap and why do they not last?

    Why are apple cords/chargers so cheap and why do they not last?  I feel like I waste my money having to buy so many.
    <Re-Titled By Host>

    I've had many chargers and cords and never had an issue.
    Must be you.

  • I have upgraded my computer to program the MAC OS X but would like to remove this update and revert to the old one. Is this possible and how do I proceed?

    I have upgraded my computer to program the MAC OS X but would like to remove this update and revert to the old one. Is this possible and how do I proceed?

    Not easily, unless you backed up your data.
    Did you?  If not, let that be a lesson to never install anything without a backup:
    https://discussions.apple.com/docs/DOC-1992
    https://discussions.apple.com/docs/DOC-1948

Maybe you are looking for

  • How do I delete OS X install data

    I have installed OS X Mavericks on a external hard drive. It gives me the ability to see my macintosh hd hard drive but I can't delete anything. On another forum it said it would fix everything with the hard drive if the 'os x install data' folder wa

  • Displaying form running status

    I have one very simple form with only one push button. This push button is running a very long procedure it may take few minutes to run, so while it is running i want to display meessage "runnig...." and as it finished it should go. I dont know how c

  • XFi Fatality pro series and front panel sound -lack of- so la

    <span class="j2">Had <span class="j2">to <span class="j2">chip <span class="j2">in <span class="j2">on <span class="j2">this <span class="j2">forum <span class="j2">as <span class="j2">I'm <span class="j2">quite <span class="j2">furious <span class="

  • I'm trying to listen to a library audiobook on my iPod

    Overdrive loaded the files, and I can see them when I look at my iPod as a drive on my computer.  But I can't play them using the iPod as a drive on my computer, and I can't find the book files on my iPod when I use the iPod menu.  Any thoughts?

  • Java Script popup error

    Hi Guys , I am getting the following error when i try to popup a OA Page from another OA page using js from Jdev the error is Error Unexpected URL parameters have been detected and will be ignored. When i move to the server this is the error You are