Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 清除Internet临时文件中的*.kml文件_C# - Fatal编程技术网

C# 清除Internet临时文件中的*.kml文件

C# 清除Internet临时文件中的*.kml文件,c#,C#,我想清除临时Internet文件中的所有kml文件。我尝试了递归目录搜索,但找不到kml文件,尽管使用windows资源管理器浏览时可以看到kml文件。在“临时Internet文件”的实际目录(如Content.IE5)中,这些kml文件存在*.xml对应项。我也删除了它们,但windows资源管理器仍然显示kml文件。 我还尝试了一些WinApi方法,但我无法编写我想要的代码 据我所知,临时互联网文件的处理方式与回收站文件类似,即有一个包含元数据(如文件名)的索引文件和包含实际内容的文件。您可

我想清除临时Internet文件中的所有kml文件。我尝试了递归目录搜索,但找不到kml文件,尽管使用windows资源管理器浏览时可以看到kml文件。在“临时Internet文件”的实际目录(如Content.IE5)中,这些kml文件存在*.xml对应项。我也删除了它们,但windows资源管理器仍然显示kml文件。
我还尝试了一些WinApi方法,但我无法编写我想要的代码

据我所知,临时互联网文件的处理方式与回收站文件类似,即有一个包含元数据(如文件名)的索引文件和包含实际内容的文件。您可能可以使用来获取文件信息,但我认为没有任何特定/简单的方法可以清除除特定子集以外的所有文件(而不会像您这样简单地删除文件而不更新元数据或迭代缓存中的所有文件),从而损坏缓存文件)

编辑:我误解了你(我想,你只是想删除一组特定的文件,而不是其他所有文件)。如果只想删除所有*.kml文件,可以执行以下操作:

  • 使用
    findfirsturlcachentry
    和`FindNextUrlCacheEntry>查找缓存项
  • 使用
    DeleteUrlCacheEntry
    删除找到的条目

您是否尝试过
环境.SpecialFolder.InternetCache
路径

        string tempPath = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);

        System.IO.DirectoryInfo tempDir = new DirectoryInfo(tempPath );
        foreach (FileInfo file in tempDir.GetFiles("*.kml"))
        {
            file.Delete();
        }
您还应该更新代码以删除子目录中的文件


希望能有所帮助。

谢谢你的回答,我使用了