Here's an interesting solution in c# from Iteration at NullCoders.com.
using System;
using System.Windows.Forms;
using System.IO;
private void GhostFolder(string FolderPath)
{
try
{
DirectoryInfo di = new DirectoryInfo(@FolderPath);
string TempPath = di.Parent.FullName + "\\GhostedTempFolder";
if (Directory.Exists(TempPath) == true)
{
foreach (string Path in Directory.GetFiles(TempPath, "*.*", SearchOption.AllDirectories))
File.Delete(Path);
Directory.Delete(TempPath);
}
Directory.CreateDirectory(TempPath);
File.Delete(TempPath + "\\desktop.ini");
File.SetAttributes(TempPath, FileAttributes.System);
StreamWriter file = new System.IO.StreamWriter(TempPath + "\\desktop.ini");
file.WriteLine("[.ShellClassInfo]");
file.WriteLine("IconResource=C:\\Windows\\system32\\SHELL32.dll,49");
file.Close();
foreach( string folders in Directory.GetDirectories(@FolderPath, "*.*", SearchOption.AllDirectories))
Directory.CreateDirectory(folders.Replace(FolderPath, TempPath));
foreach (string files in Directory.GetFiles(@FolderPath, "*.*", SearchOption.AllDirectories))
File.Copy(files, files.Replace(FolderPath,TempPath));
DirectoryInfo HiddenFolder = new DirectoryInfo(@TempPath);
string NewName = HiddenFolder.FullName.Replace(HiddenFolder.Name, char.ConvertFromUtf32(160));
HiddenFolder.MoveTo(NewName);
HiddenFolder.Refresh();
Directory.Delete(@FolderPath, true);
GC.Collect();
MessageBox.Show("Folder was successfully ghosted, may take a few minutes for windows to refresh the cache.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ee)
{
MessageBox.Show(ee.Message);
}
}