private void btnRequestFileSize_ClickButtonArea(object Sender, MouseEventArgs e) { // Request file size from URL buttonRequestFileSize.Visible = false; BackGroundWorker.RunWorkAsync <string>(() => TextExtensions.BytesToString(WebFileExtensions.GetFileSize(currentFile.URL)), (data) => { infoSize.Text = data; }); }
/// <summary> /// Get web file info from internal database, or creates a new object if it doesn't exist /// </summary> /// <param name="URL">Matches URL with WebFile.URL to return object</param> /// <returns>WebFile object</returns> public static WebFile FileInfoFromURL(string URL) { // Checks loaded files for a matching URL and returns the Web File object foreach (var file in MainForm.FilesOpenDatabase) { if (file.URL == URL) { return(file); } } // Create a new Web File object as this URL doesn't exist in the database there anymore var newWebFile = new WebFile(Path.GetExtension(URL).Replace(".", "").ToUpper(), Path.GetFileNameWithoutExtension(new Uri(URL).LocalPath), WebFileExtensions.GetFileSize(URL), WebFileExtensions.GetFileLastModified(URL), new Uri(URL).Host.Replace("www.", ""), new Uri(URL).AbsoluteUri); // Add the new Web File to current local database MainForm.FilesOpenDatabase.Add(newWebFile); // Return the new Web File return(newWebFile); }