示例#1
0
        public LocalService()
        {
            FirstTime = false;
            
            if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed) {
                System.Deployment.Application.ApplicationDeployment cd = System.Deployment.Application.ApplicationDeployment.CurrentDeployment;
                Version = cd.CurrentVersion.ToString();
            } else 
                Version = "0.0.0.1";

            var path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            CompanyFolder = path + @"\ms";
            if (!Directory.Exists(CompanyFolder)) Directory.CreateDirectory(CompanyFolder);
            AppFolder = CompanyFolder + @"\ms.video.downloader";
            if (!Directory.Exists(AppFolder)) Directory.CreateDirectory(AppFolder);
            AppVersionFolder = AppFolder + @"\" + Version;
            if (!Directory.Exists(AppVersionFolder)) Directory.CreateDirectory(AppVersionFolder);
            _configFile = AppFolder + "\\applicationConfiguration.json";
            _downloadsFile = AppVersionFolder + "\\downloads.json";
            
            if (!File.Exists(_configFile)) {
                FirstTime = true;
                _configuration = new ApplicationConfiguration { Guid = Guid.NewGuid() };
                using (var file = new StreamWriter(_configFile)) {
                    file.Write(JsonConvert.SerializeObject(_configuration));
                }
            }
            using (var file = new StreamReader(_configFile)) {
                _configuration = JsonConvert.DeserializeObject<ApplicationConfiguration>(file.ReadToEnd());
            }
        }
 public DownloadListView()
 {
     this.InitializeComponent();
     _appConfig = Settings.Instance.ApplicationConfiguration;
     active.IsChecked = _appConfig.S3CanBeActive && _appConfig.S3IsActive;
     accessKey.Text = _appConfig.S3AccessKey;
     secretKey.Text = _appConfig.S3SecretAccessKey;
     UpdateS3ComboBoxes();
 }