Exemple #1
0
        private void Open()
        {
            if (listBox1.SelectedItem == null)
            {
                return;
            }

            var stream = listBox1.SelectedItem as NtfsAlternateStream;

            if (stream == null)
            {
                return;
            }


            OpenOrSave   form         = new OpenOrSave();
            DialogResult dialogResult = form.ShowDialog();

            if (dialogResult != DialogResult.OK && dialogResult != DialogResult.Yes)
            {
                return;
            }

            if (form.OpenSave == OpenSave.Open)
            {
                string   text     = NtfsAlternateStream.ReadAllText(_path + stream.Name);
                TextView textView = new TextView(text);
                textView.Show();
            }
            else if (form.OpenSave == OpenSave.Save)
            {
                SaveFileDialog dialog = new SaveFileDialog();
                dialog.FileName = ConvertUtilities.ToFileName(stream.Name);
                DialogResult showDialog = dialog.ShowDialog();
                if (showDialog != DialogResult.OK && showDialog != DialogResult.Yes)
                {
                    return;
                }

                using (var dstStream = dialog.OpenFile())
                {
                    using (var srcStream = NtfsAlternateStream.Open(_path + stream.Name, FileAccess.Read, FileMode.Open, FileShare.Read))
                    {
                        srcStream.CopyTo(dstStream);
                    }
                }
            }
        }