Esempio n. 1
0
        public void FillContents(string file_name)
        {
            //directory or file?

            FileName = file_name;
            var            file_hanle = IntPtr.Zero;
            var            win_err    = 0;
            Win32Exception win_ex     = null;

            try
            {
                if (IOhelper.IsDirectory(file_name))
                {
                    file_hanle = WinApiFS.CreateFile_intptr
                                     (file_name,
                                     Win32FileAccess.GENERIC_READ,
                                     FileShare.ReadWrite,
                                     IntPtr.Zero,
                                     FileMode.Open,
                                     CreateFileOptions.BACKUP_SEMANTICS,
                                     IntPtr.Zero);
                }
                else
                {
                    file_hanle = WinApiFS.CreateFile_intptr
                                     (file_name,
                                     Win32FileAccess.GENERIC_READ,
                                     FileShare.ReadWrite,
                                     IntPtr.Zero,
                                     FileMode.Open,
                                     CreateFileOptions.None,
                                     IntPtr.Zero);
                }

                if (file_hanle.ToInt64() == WinApiFS.INVALID_HANDLE_VALUE)
                {
                    win_err = Marshal.GetLastWin32Error();
                    win_ex  = new Win32Exception(win_err);
                    return;
                }

                FillContents(file_hanle);
            }
            finally
            {
                if ((file_hanle != IntPtr.Zero) && (file_hanle.ToInt64() != WinApiFS.INVALID_HANDLE_VALUE))
                {
                    WinApiFS.CloseHandle(file_hanle);
                }

                if (win_ex != null)
                {
                    var fake_info = new NT_FILE_STREAM_INFORMATION();
                    fake_info.StreamName = win_ex.Message;
                    listViewStreams.Items.Add(new InternalListViewItem(fake_info));
                }
            }
        }
Esempio n. 2
0
        public void FillContents(string file_name)
        {
            FileName = file_name;
            Text     = file_name;

            is_directory = IOhelper.IsDirectory(file_name);

            FillStandardPage(file_name);
        }
Esempio n. 3
0
        protected override void internal_command_proc()
        {
            QueryPanelInfoEventArgs e = new QueryPanelInfoEventArgs();

            OnQueryCurrentPanel(e);

            if (e.FocusedIndex == -1)
            {
                return;
            }

            DirectoryList dl = (DirectoryList)e.ItemCollection;

            int[] sel_indices = e.SelectedIndices;
            //we must cache selection
            //becouse indexes will be change while deleting
            List <string> sel_names = new List <string>();

            if (sel_indices.Length > 0)
            {
                for (int i = 0; i < sel_indices.Length; i++)
                {
                    sel_names.Add(Path.Combine(dl.DirectoryPath, dl.GetItemDisplayNameLong(sel_indices[i])));
                }
            }
            else
            {
                sel_names.Add(Path.Combine(dl.DirectoryPath, dl.GetItemDisplayNameLong(e.FocusedIndex)));
            }

            //prepare dialog
            DeleteFileDialog dialog = new DeleteFileDialog();

            dialog.Text = "Delete files";
            if (sel_names.Count == 1)
            {
                if (IOhelper.IsDirectory(sel_names[0]))
                {
                    dialog.labelQuestion.Text = string.Format("Do you REALLY want to delete '{0}'? This directory and all its contents it will be destroyed for ever.", sel_names[0]);
                }
                else
                {
                    dialog.labelQuestion.Text = string.Format("Do you REALLY want to delete '{0}'? The file will be destroyed for ever.", sel_names[0]);
                }
            }
            else
            {
                dialog.labelQuestion.Text = string.Format("Do you REALLY want to delete {0} entries? All selected files and directories with the contents will be destroyed for ever.", sel_names.Count);
            }
            dialog.checkBoxForceReadonly.Checked     = Options.DeleteReadonly;
            dialog.checkBoxSupressExceptions.Checked = Options.DeleteSupressExceptions;

            if (dialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            //save user selection
            Options.DeleteReadonly          = dialog.checkBoxForceReadonly.Checked;
            Options.DeleteSupressExceptions = dialog.checkBoxSupressExceptions.Checked;
            force_readonly     = dialog.checkBoxForceReadonly.Checked;
            supress_exceptions = dialog.checkBoxSupressExceptions.Checked;

            //and enum entries in sel_names and recursively delete each
            foreach (string one_name in sel_names)
            {
                delete_file_recurs(one_name);
            }
        }