C# .NET - making data recovery software -

Hi

refer the links

it might help you
http://www.c-sharpcorner.com/Forums/Thread/54387/
http://www.freelancer.com/projects/Java-Visual-Basic/Data-recovery-software.723158.html
Riley K replied to murtaza rampurawala on 14-Jun-11 04:10 AM

Hi

 

I dont think there are any classes to do this in C#. You need to use some free softwares to do this.

 

http://lifehacker.com/393084/how-to-recover-deleted-files-with-free-software

Jitendra Faye replied to murtaza rampurawala on 14-Jun-11 04:11 AM
Such an application I believe uses low level APIs. You must first find a way to scan the harddrive for deleted data, and then process that data to find typical file type headers. C# like most other languages can certanly be used to process the data once you find it.

follow this link-

http://www.codeproject.com/Messages/3553742/Csharp-program-to-recover-data.aspx

Hope this will help you.
Kirtan Patel replied to murtaza rampurawala on 14-Jun-11 04:53 AM
you can start by using win32 API Functions to access the FAT allocation table of recovery 

[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
static extern IntPtr FindFirstFile(string lpFileName, out WIN32_FIND_DATA lpFindFileData);
Here is sample code how to use that code 

[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
static extern IntPtr FindFirstFile(string lpFileName, out WIN32_FIND_DATA lpFindFileData);
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern SafeFindHandle FindFirstFile(string lpFileName, out WIN32_FIND_DATA lpFindFileData);
 
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool FindClose(SafeHandle hFindFile);
 
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern bool FindNextFile(SafeHandle hFindFile, out WIN32_FIND_DATA lpFindFileData);
 
internal sealed class SafeFindHandle : SafeHandleZeroOrMinusOneIsInvalid
{
// Methods
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
internal SafeFindHandle()
: base(true)
{
}
 
public SafeFindHandle(IntPtr preExistingHandle, bool ownsHandle) : base(ownsHandle)
{
  base.SetHandle(preExistingHandle);
}
 
protected override bool ReleaseHandle()
{
if (!(IsInvalid || IsClosed))
{
  return FindClose(this);
}
  return (IsInvalid || IsClosed);
}
 
protected override void Dispose(bool disposing)
{
if (!(IsInvalid || IsClosed))
{
  FindClose(this);
}
base.Dispose(disposing);
}
}
 
private long RecurseDirectory(string directory, int level, out int files, out int folders) {
IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1);
long size = 0;
files = 0;
folders = 0;
Kernel32.WIN32_FIND_DATA findData;
 
// please note that the following line won't work if you try this on a network folder, like \\Machine\C$
// simply remove the \\?\ part in this case or use \\?\UNC\ prefix
using(SafeFindHandle findHandle = Kernel32.FindFirstFile(@"\\?\" + directory + @"\*", out findData))
  {
  if (!findHandle.IsInvalid) {
 
  do {
    if ((findData.dwFileAttributes & FileAttributes.Directory) != 0) {
 
      if (findData.cFileName != "." && findData.cFileName != "..") {
        folders++;
 
        int subfiles, subfolders;
        string subdirectory = directory + (directory.EndsWith(@"\") ? "" : @"\") +
          findData.cFileName;
        if (level != 0)  // allows -1 to do complete search.
          {
        size += RecurseDirectory(subdirectory, level - 1, out subfiles, out subfolders);
 
        folders += subfolders;
        files += subfiles;
        }
      }
    }
    else {
      // File
      files++;
 
      size += (long)findData.nFileSizeLow + (long)findData.nFileSizeHigh * 4294967296;
    }
  }
  while (Kernel32.FindNextFile(findHandle, out findData));
  }
 
}
 
return size;
}

 
 
posted @ 2015-08-20 08:57  applekingghfhfhbr  阅读(468)  评论(0编辑  收藏  举报