Ejemplo n.º 1
0
        public void MoveTo(string destFileName)
        {
            var prefixFullname     = PREFIX + filename;
            var prefixFullnameCopy = PREFIX + destFileName;
            var fileHandleFrom     = ExternalCalls.CreateFile(prefixFullname,
                                                              ExternalCalls.ExtFileAccess.GenericRead, ExternalCalls.ExtFileShare.Read, IntPtr.Zero,
                                                              ExternalCalls.ECreationDisposition.OpenExisting, 0, IntPtr.Zero);

            byte[] buffer;
            using (var fileStream = new FileStream(fileHandleFrom, FileAccess.Read))
            {
                buffer = new byte[fileStream.Length];
                fileStream.Read(buffer, 0, buffer.Length);
            }
            fileHandleFrom.Close();
            var fileHandleTo = ExternalCalls.CreateFile(prefixFullnameCopy,
                                                        ExternalCalls.ExtFileAccess.GenericWrite, ExternalCalls.ExtFileShare.Write, IntPtr.Zero,
                                                        ExternalCalls.ECreationDisposition.CreateAlways, 0, IntPtr.Zero);

            using (var fileStream = new FileStream(fileHandleTo, FileAccess.Write))
            {
                fileStream.Write(buffer, 0, buffer.Length);
            }
            fileHandleTo.Close();
            ExternalCalls.DeleteFile(prefixFullname);
        }
Ejemplo n.º 2
0
        public void Delete()
        {
            var prefixFullname = PREFIX + filename;

            ExternalCalls.DeleteFile(prefixFullname);
        }