예제 #1
0
        private void Create_Click(object sender, RoutedEventArgs e)
        {
            var name = NewSnippetName.Text;

            if (!name.EndsWith(FileExtensions.TypeExtension))
            {
                name += FileExtensions.TypeExtension;
            }

            var newType = new POSHToolbeltType();

            newType.HasMultipleValues = true;
            newType.Name = name.Substring(0, name.LastIndexOf(FileExtensions.TypeExtension));

            var fileText = JsonConvert.SerializeObject(newType, Formatting.Indented);

            var fileAttributes = File.GetAttributes(_Path);

            if (fileAttributes.HasFlag(FileAttributes.Directory))
            {
                File.WriteAllText(Path.Combine(_Path, name), fileText);
            }
            else
            {
                var directory = Path.GetDirectoryName(_Path);
                File.WriteAllText(Path.Combine(directory, name), fileText);
            }

            FileBrowserService.RefreshTreeView();
            Close();
        }
예제 #2
0
        private void Create_Click(object sender, RoutedEventArgs e)
        {
            var directoryName = NewFolderName.Text;

            Directory.CreateDirectory(Path.Join(_Path, directoryName));
            FileBrowserService.RefreshTreeView();
            Close();
        }