找不到“已保存"目录网页 [英] Not finding directory for "saved" web pages

查看:58
本文介绍了找不到“已保存"目录网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我有一个例程,该例程以递归方式浏览文件夹并监视文件夹中的文件并等待更改.找到对文件夹的更改后,更改的文件将镜像到另一个目录.到目前为止,该方法效果很好,但是我注意到了一个怪癖.将网页保存到受监视的目录时,会产生错误.我想出了原因:当您保存页面(如从firefox)时,它将相关文件保存在(.html/.aspx/whatever)文件旁边的隐藏目录中以重新创建它.但是,.net在保存网页时看不到该目录,因此它可以复制文件,但找不到随附的目标目录.这有意义吗?:confused:

有什么想法吗?这背后有很多代码,所以我将为您保留一个帖子.基本上,我在文件夹上使用文件系统监视程序来监视更改,然后在创建它们时将它们复制过来.这个网页的事情很奇怪,因为正在复制的文件引发了FILES事件,但没有引发目录事件.其他一切都可以正常工作.

谢谢

D:cool:

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:

推荐答案



当浏览器(例如IE7或FF3)将网页另存为X.htm时,它还会创建一个包含所有包含文件的文件夹X_files.该文件夹位于接收X.htm的同一文件夹中.
备注:
1.文件夹名称之夜因不同的语言/地区而异.
1.您可以通过查看X.htm文件来检查确切的文件夹名称;对图像的任何引用(img src ="X_files/someImage")都应显示确切的文件夹名称.

AFAIK X_files文件夹在任何方面都不是特殊的,也不是隐藏的.并且FileSystemWatcher应该在得到指示时发信号通知其创建.

此外,您不需要单独的信号,您应该做的是:
1.收到信号X.htm被创建
2.等待几秒钟,以便X.htm和X_files文件夹被创建并完全写入
3.然后从单个信号中,自己处理它们.

:)
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.

:)


Luc,

您会发现自己的发现.我的错误是假设它与自动创建的目录有关.答案实际上是对我而言不好的编码:我有一段代码对传递的目录进行测试,以根据索引是否为"确定它是文件还是目录.路径中的任何地方.我的错.哈哈.好吧,显然您可以在目录路径中带有.".其中正是您保存网页时发生的情况:它创建目录thefile.aspx_files.

由于该文件夹的Windows行为,即当您仅移动单个.aspx文件时,它会移动文件夹,因此在复制时,我认为它与此有关.

切换到使用system.io.file.exists(thePath)测试传递的路径的问题得以解决.

感谢您的帮助!
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!


这篇关于找不到“已保存"目录网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆