Пример #1
0
        public void ChangeExtension()
        {
            var directory = ApplicationPaths.RootDirectory;
            var fileInfo = new FileInfo(directory + "\\foo.bar");

            CreateFoo();
            if (File.Exists(directory + "\\foo.foo")) File.Delete(directory + "\\foo.foo");

            Assert.IsTrue(fileInfo.Exists);
            fileInfo = fileInfo.ChangeExtension("foo");
            Assert.IsTrue(File.Exists(directory + "\\foo.foo"));
        }
        public void ChangeExtension()
        {
            // Type
            var @this = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Examples_System_IO_FileInfo_ChangeExtension.txt"));
            var @thisNewFile = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Examples_System_IO_FileInfo_ChangeExtension.cs"));

            // Intialization
            using (FileStream stream = @this.Create())
            {
            }

            // Examples
            string result = @this.ChangeExtension("cs");

            // Unit Test
            Assert.AreEqual(@thisNewFile.FullName, result);
        }
Пример #3
0
        private void Process(FileInfo file)
        {
            var input = string.IsNullOrWhiteSpace(Input)
                            ? file.Extension.Substring(1)
                            : Input;
            var destination = file.ChangeExtension(".{0}".FormatWith(Output));
            switch (input.ToUpperInvariant())
            {
                case "CSV":
                    Process(new CsvDataSheet(file), destination);
                    break;

                case "TSV":
                    Process(new TsvDataSheet(file), destination);
                    break;

                default:
                    throw new FormatException("{0} is not a supported input data format.".FormatWith(input));
            }
        }