如何使用 C# 取消删除文件?

发布于 2024-08-03 21:32:23 字数 502 浏览 10 评论 0原文

我正在尝试寻找一些丢失的 .jpg 图片。这是一个 .bat 文件,用于设置我的情况的简化版本

md TestSetup
cd TestSetup
md a
cd a
echo "Can we find this later?" > a.abc
del a.abc
cd..
rd a

需要什么代码才能再次打开该文本文件?我实际上正在寻找以类似方式处理的 .jpeg 文件

更多详细信息:我正在尝试从以前的一键式备份中恢复图片文件,其中目录和文件已被删除,并且所有内容都保存在备份中单字符名称,每个文件都有相同的 3 个字母扩展名。有当前备份,但他们需要查看以前删除的备份(或至少是 .jpg 文件)。

这是我尝试解决它的方法: C# 代码

I'm trying to find some lost .jpg pictures. Here's a .bat file to setup a simplified version of my situation

md TestSetup
cd TestSetup
md a
cd a
echo "Can we find this later?" > a.abc
del a.abc
cd..
rd a

What code would be needed to open the text file again? I'm actually looking for .jpeg files that were treated in a similar manner

More details: I'm trying to recover picture files from a previous one-touch backup where the directories and files have been deleted and everything was saved in the backup with a single character name and every file has the same 3 letter extension. There is a current backup but they need to view the previous deleted ones (or at least the .jpg files).

Here's how I was trying to approach it: C# code

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖阳 2024-08-10 21:32:23

据我所知,大多数文件恢复工具实际上读取磁盘上的低级文件系统格式并尝试将已删除的文件拼凑在一起。这是有效的,因为至少在 FAT 中,已删除的文件仍然驻留在指定目录的扇区中(只是使用不同的第一个字符来将其标识为“已删除”)。新文件可能会覆盖这些已删除的条目,从而使文件无法恢复。这只是一点点理论。

有一个当前备份,但它们
需要查看之前删除的
(或者至少是 .jpg 文件)。

除非您想要恢复时该文件的备份,否则我相信您将很难在不诉诸低级文件系统读取的情况下获取该文件。即便如此,如果进行了足够的修改(或者它不是像 FAT 这样的简单文件系统),您可能会运气不好。

To the best of my knowledge, most file recovery tools actually read the low-level filesystem format on the disk and try to piece together deleted files. This works because, at least in FAT, a deleted file still resides in the sector specifying the directory (just with a different first character to identify it as "deleted"). New files may overwrite these deleted entries and therefore make the file unrecoverable. That's just a little bit of theory.

There is a current backup but they
need to view the previous deleted ones
(or at least the .jpg files).

Unless there's a backup for that file at the time that you want to restore from, I believe you're going to have a hard time getting that file without resorting to a low-level filesystem read. And even then, you may be out of luck if enough revisions have been made (or it's not a trivial filesystem like FAT).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文