bibikurosawa / dokan

Automatically exported from code.google.com/p/dokan
0 stars 0 forks source link

Workaround for DeleteFile (works great) for .NET #74

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Tested on WinXp Sp2

In DokanNet Proxy.cs
make DOKAN_FILE_INFO public, something like:

[StructLayout(LayoutKind.Sequential, Pack = 4)]
    public struct DOKAN_FILE_INFO
    {
        public ulong Context;
        public ulong DokanContext;
        public uint ProcessId;
        public byte IsDirectory;
        public byte DeleteOnClose;
        public IntPtr Dummy;
    }

In DokanOperations, extend DokanFileInfo with DOKAN_FILE_INFO, something
like this:
public class DokanFileInfo
    {
        public Object Context;
        public bool IsDirectory;
        public ulong InfoId;
        public uint ProcessId;
        public DOKAN_FILE_INFO fInfo;

        public DokanFileInfo()
        {
            Context = null;
            IsDirectory = false;
            InfoId = 0;
        }
    }
DeleteFile in file system implementation allways return 0;
In CloseFile make something like this:

if (info != null)
            {
                if (info.fInfo.DeleteOnClose != 0)
                {
                    // delete your file, identified by filename
                }
}

Works with total commander and windows explorer.

Original issue reported on code.google.com by ninkovsl...@gmail.com on 11 Mar 2009 at 1:59