【Vtt2Srt】Console主程序

本文介绍了一个名为Vtt2Srt的转换工具的实现细节,该工具用于将VTT文件转换为SRT文件。文章展示了如何通过命令行方式运行此工具,并详细解释了程序的Main函数及异常处理部分。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Vtt2Srt工具最终会有一个console和WPF主程序,所以共用的部分会放到一个单独的程序集里面。

以下是Console程序的最顶端


using System;
using Autofac;
using Vtt2Srt.Core;
 
namespace Vtt2Srt.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                if (args.Length < 1)
                    throw new Exception("The program should be running with 1 argument at least.");
 
                var processor = BuilderVtt2SrtProcessor();
                processor.Process(args[0]);
 
                System.Console.WriteLine("The conversion has been done.\nPlease find srt file at the same directory where vtt file is.");
            }
            catch (Exception exception)
            {
                System.Console.WriteLine(exception.Message + "\n\n" + exception.StackTrace);
            }
        }
 
        private static VttToSrtProcessor BuilderVtt2SrtProcessor()
        {
            var bootstrapper = new Bootstrapper();
            var container = bootstrapper.Bootstrap();
            return container.Resolve<VttToSrtProcessor>();
        }
    }
}
一般来说,Main函数里面就应该很简单......
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值