使用Windows应用程序在c#中文件或目录已损坏且无法读取 [英] file or directory is corrupted and unreadable in c# using windows application

查看:168
本文介绍了使用Windows应用程序在c#中文件或目录已损坏且无法读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Windows应用程序

解决方案

文件或目录在c#中已损坏且无法读取作为一般解决方案,如果文件,文件夹或文件系统索引可能会发生此行为(主文件表[MFT]或文件分配表[FAT])已损坏。



尝试使用Chkdsk修复损坏的文件,文件夹或文件系统索引。为此,请按照下列步骤操作

1.单击开始,然后单击运行。

2.在打开框中,键入chkdsk / f< drive> :,其中< drive>是存在损坏的文件,文件夹或文件系统索引的驱动器号。

3.单击OK。


作为文件写入操作的解决方案,写缓存不会导致文件损坏。在文件打开时关闭机器会导致文件损坏。



如果您捕获了异常,那么您应该能够删除该文件。



如果您在写入日志文件时调用Flush,则可以减少错误的频率。如果在每次写入后关闭文件,您几乎可以完全消除错误(当然,这需要您在每次写入之前打开它以进行追加)。这可能是非常昂贵的。



只要关闭应用程序的唯一方法是断电,就不能完全消除错误。你可以考虑旋转日志,所以如果它确实被破坏你只会丢失最后一个小时左右。


文件系统,更确切地说,MFT或文件分配表是可能的已经损坏。它可能是由驱动器仍在工作时磁盘弹出引起的。它也可能是由病毒感染引起的。为了解决这个问题,你可以

第1步:使用恢复应用程序从驱动器中检索数据。由于现在无法打开,您需要使用专业工具恢复数据。

如果驱动器上没有重要数据,您可以跳过步骤1并尝试以下解决方案:

解决方案1:直接格式化驱动器。您可以使用快速格式在磁盘管理或Windows资源管理器中对其进行格式化。

解决方案2:执行ChkDsk以修复文件系统错误。 chkdsk / fg: g是相关分区的驱动器号,在你的情况下它可以是其他字母。

键入Y并按Enter键并重新启动计算机以恢复磁盘检查是否收到消息Chkdsk无法运行,因为另一个进程正在使用该卷。您是否要在下次系统重新启动时安排检查此卷?

了解详细步骤截图你可以去 http://www.eassos。 com / how-to / the-file-or-directory-is-corrupted-and -readreadable.php [ ^ ]


file or directory is corrupted and unreadable in c# using windows application

解决方案

As the general solution, this behavior can occur if the file, folder or file system index (Master File Table [MFT] or File Allocation Table [FAT]) is damaged.

As an attempt to repair the damaged file, folder or file system index using Chkdsk. To do so, follow these steps
1. Click Start, and then click Run.
2. In the Open box, type chkdsk /f <drive>:, where <drive> is the letter of the drive on which the damaged file, folder or file system index exists.
3. Click OK.


As the solution against file write operation, write caching doesn't cause file corruption. Shutting the machine off while the file is open causes the file corruption.

If you capture the exception then you should be able to delete the file.

You can probably lessen the frequency of errors if you call Flush on the log file whenever you write to it. You can almost completely eliminate the error if you close the file after every write (which, of course, would require that you open it for append before every write). That might be prohibitively expensive.

You can't completely eliminate the error as long as the only way to shut down the application is to remove power. You might consider rotating the log, though, so if it does get corrupted you only lose the last hour or so.


it's possible that files system, more exactly, the MFT or file allocation table is damaged. it may be caused by disk ejecting while the drive is still working. also it might be caused by virus infection. to fix this you can
step 1: retrieve data from the drive with recovery apps. since it can't be opened now, you need to restore data with professional tools.
If there is no important data on the drive, you can skip the step 1 and try the following solution:
Solution 1: format the drive directly. you can either format it under Disk Management or Windows Explorer with Quick Format.
Solution 2: carry out ChkDsk to repair file system errors. chkdsk /f g: g is the drive letter of the partition in question and it can be other letter in your case.
Type Y and hit Enter and restart computer to resume disk check if you get the message "Chkdsk cannot run because the volume is in use by another process. Would you like to schedule this volume to be checked the next time the system restarts? "
for detailed steps with screenshot you can go http://www.eassos.com/how-to/The-file-or-directory-is-corrupted-and-unreadable.php[^]


这篇关于使用Windows应用程序在c#中文件或目录已损坏且无法读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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