Пример #1
0
        /// <summary>
        /// Get web file info from internal database, or creates a new object if it doesn't exist
        /// </summary>
        /// <param name="URL">Used to match with WebFile.URL to return class</param>
        /// <returns>WebFile object</returns>
        public static WebFile WebFile(string URL)
        {
            // Checks loaded files for a matching URL and returns the Web File object
            foreach (var file in MainForm.DbOpenFiles)
            {
                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.FtpFileSize(URL), WebFileExtensions.FtpFileTimestamp(URL), new Uri(URL).Host.Replace("www.", ""), new Uri(URL).AbsoluteUri);

            // Add the new Web File to this instance of application
            MainForm.DbOpenFiles.Add(newWebFile);

            // Return the new Web File
            return(newWebFile);
        }
Пример #2
0
 private void ButtonRequestSize_Click(object sender, EventArgs e)
 {
     // Request file size from URL
     ButtonRequestSize.Visible = false;
     BackGroundWorker.RunWorkAsync <string>(() => StringExtensions.BytesToPrefix(WebFileExtensions.FtpFileSize(CurrentFile.URL)), (data) => { LabelValueSize.Text = data; });
 }