Click here to Skip to main content
16,004,678 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So, I have a routine that is navigating folders recursively and monitoring files in the folders and waiting for changes. When a change to a folder is found, the changed files are mirrored to another directory. This works great so far, however I've noticed a quirk. When saving a web page to the monitored directory, it creates an error. I figured out why: When you save the page (like from firefox) it saves the related files in a hidden directory alongside the (.html/.aspx/whatever) file to recreate it. However, .net isn't seeing this directory when the web page is saved, so it goes to copy the files, but without finding the accompanying destination directory. Does that make sense?:confused:

Any thoughts? There is a lot of code behind this so I'll spare you a posting. Basically I'm using a file system watcher on folder to monitor changes and then just copying them over when they are created. This web page thing is odd because the files that are copying raise the event for the FILES, but never for the directory. Everything else works hunky dory.

thanks

D:cool:
Posted

Hi,

when a browser (e.g. IE7 or FF3) saves a web page as X.htm, it also creates a folder X_files with all included files. That folder is located in the same one that receives X.htm

Remarks:
1. the folder name night vary for different languages/regions.
1. you can check the exact folder name by looking into the X.htm file; any reference to images (img src="X_files/someImage") should reveal the exact folder name.

AFAIK the X_files folder isn't special in any way, it is not hidden. And FileSystemWatcher should signal its creation when instructed to do so.

Furthermore, you don't need a separate signal, what you should do is:
1. get a signal X.htm got created
2. wait a few seconds so X.htm and the X_files folder are created and completely written
3. then from that single signal, process them all yourself.

:)
 
Share this answer
 
Luc,

You are spot on with your observations. My mistake was assuming it had something to do with the automatically created directory. The answer was actually bad coding on my part: I had a piece of code that tested the passed directory to determine if it was a file or directory based on if there was an index of "." anywhere in the path. My bad. LOL. Well, obviously you can have a directory path with a "." in it, which is precisely what happens when you save the web page: it creates the directory thefile.aspx_files.

Because of windows behavior with the folder, namely that it moves the folder when you just move the single .aspx file, when copying, I assumed it had something to do with that.

A switch to testing the passed path with system.io.file.exists(thePath) fixed the prob.

Thanks for the help!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900