private void ReporterViewer_Loaded(object sender, RoutedEventArgs e) { try { string BaseDirectoryPath = AppDomain.CurrentDomain.BaseDirectory; if (Directory.Exists("TEMP/") == false)//如果不存在就创建file文件夹 { Directory.CreateDirectory("TEMP/"); } if (File.Exists(BaseDirectoryPath + "TEMP\\" + url.Substring(url.LastIndexOf("/") + 1) + "Reporter.pdf")) { FileInfo fi = new FileInfo(BaseDirectoryPath + "TEMP\\" + url.Substring(url.LastIndexOf("/") + 1) + "Reporter.pdf"); fi.Attributes = FileAttributes.Normal; fi.IsReadOnly = false; fi.Delete(); } bool check = false; while (!check) { check = DownloadFile.Download(url, "TEMP/" + url.Substring(url.LastIndexOf("/") + 1) + "Reporter.pdf"); } ReporterViewer.LoadFile(BaseDirectoryPath + "/TEMP/" + url.Substring(url.LastIndexOf("/") + 1) + "Reporter.pdf"); } catch (Exception exp) { MessageBox.Show("文件操作异常,可能文件已经打开,请检查确认!"); return; } }
public void GetSupportedLanguages(Action <SupportedLanguages> action) { if (!File.Exists(languagesFile)) { return; } StartCoroutine(DownloadFile.Download(languagesFile, (string jsonString) => { SupportedLanguages supportedLanguages = JsonUtility.FromJson <SupportedLanguages>(jsonString); action.Invoke(supportedLanguages); })); }
void GetText(string filePath, string key, Action <string> action) { LocalizedTexts localizedTexts = null; StartCoroutine(DownloadFile.Download(filePath, (string jsonString) => { localizedTexts = JsonUtility.FromJson <LocalizedTexts>(jsonString); LocalizationItem item = localizedTexts.items.Find(o => o.key == key); string result = ""; if (item != null) { result = item.value; } action.Invoke(result); })); }
//http://www.nbp.pl/banki_w_polsce/ewidencja/dz_bank_jorg.txt public FileInfo GetFile(string path) { string fileName = Path.GetFileName(path); FileInfo fi = new FileInfo(@"download/"+fileName); bool fileExist; //= Directory.Exists("download") && File.Exists("download/myfile.txt"); fileExist = fi.Exists; if (!fileExist) { DownloadFile dw = new DownloadFile(); fileExist = dw.Download(path); } return fi; }
// the main tasks of an update public static void MainTasks(string year) { // download file DownloadFile dlf = new DownloadFile(year); string success = dlf.Download(); // returns null if no download or filename if success if (success != null) { Console.WriteLine("PPR file downloaded sucessfuly"); Trace.TraceInformation("worker role: PPR file downloaded sucessfuly"); List <Record> recordList = dlf.ConvertFile(success); // returns list of record objects for sorting if (recordList != null || recordList.Count > 0) // list is null if has thrown exception or could be empty { CleanUpRecords cur = new CleanUpRecords(); List <AlteredRecord> alteredRecords = cur.CleanRecords(recordList); // clean records and return an altered record list AddToDatabase atb = new AddToDatabase(); atb.AddList(alteredRecords, dateTimeUpdatedTo); // send list of to be broken down into counties and added to database documents AlterUpdateDates(); // change the dates in the update document to the new dates } } }
//加载单个音频 private bool LoadAuido(Audio audio) { return(DownloadFile.Download(Setting.SEVER_URL + audio.src, "TEMP/" + audio.src.Substring(audio.src.LastIndexOf("/")))); //return DownloadFile.Download("http://202.117.216.251:8080/" + audio.src, "TEMP/" + audio.src.Substring(audio.src.LastIndexOf("/"))); }