示例#1
0
        public static string ReloadStci(string aFileName)
        {
            IStci _stci = LoadStci(aFileName);

            using (FileStream _fs = new FileStream(aFileName, FileMode.Create))
                _stci.Save(_fs);
            return(_stci.ToString());
        }
示例#2
0
        public async void Execute(object parameter)
        {
            TestViewModel _viewModel = (TestViewModel)parameter;

            this.IsCanExecute = false;
            this.IsCanExecute = await Task.Run <bool>(() =>
            {
                try
                {
                    _viewModel.StatusString = String.Empty;
                    _viewModel.ResultString = String.Empty;
                    _viewModel.StatusString = String.Empty;

                    int i = 0;
                    string _folderName = Path.Combine(
                        Path.GetDirectoryName(_viewModel.FileName),
                        Path.GetFileNameWithoutExtension(_viewModel.FileName));

                    Directory.CreateDirectory(_folderName);

                    using (FileStream _input = new FileStream(_viewModel.FileName, FileMode.Open))
                    {
                        using (BinaryReader _br = new BinaryReader(_input))
                        {
                            while (_input.Position < _input.Length)
                            {
                                IStci _stci = StciLoader.LoadStci(_input);
                                i++;
                                string _fileName = Path.Combine(_folderName, i.ToString() + ".STI");
                                using (FileStream _output = new FileStream(_fileName, FileMode.Create))
                                {
                                    _stci.Save(_output);
                                }
                            }
                        }
                    }

                    _viewModel.StatusString = "Done";
                }
                catch (Exception exc)
                {
                    _viewModel.ErrorString = Common.GetErrorString(exc);
                }

                return(true);
            });
        }