private void Program_info_Load(object sender, EventArgs e) { label_command.Text = text; label_info.Text = infotext; FileInfo file = new FileInfo(text); try { pictureBox1.Image = ShellIcon.GetLargeIcon(file.FullName).ToBitmap(); } catch { } dontdothis = false; }
private void displayfileinfo() { textBox1.ForeColor = Color.Red; try { if (Directory.Exists(path) == true) { this.Height = 260; textBox1.ForeColor = Color.Blue; label_date_createds.ForeColor = Color.Blue; label_location.ForeColor = Color.Blue; DirectoryInfo info = new DirectoryInfo(path); label_location.Cursor = Cursors.Hand; label_name.Text = info.Name; label_location.Text = info.FullName; label_date_createds.Text = info.CreationTime.ToLongDateString() + " " + info.CreationTime.ToLongTimeString(); label_date_modified.Text = info.LastWriteTime.ToLongDateString() + " " + info.LastWriteTime.ToLongTimeString(); button1.BackgroundImage = ShellIcon.GetLargeIcon(path).ToBitmap(); } else if (File.Exists(path) == true) { this.Height = 260; textBox1.ForeColor = Color.Blue; label_date_createds.ForeColor = Color.Blue; label_location.ForeColor = Color.Blue; FileInfo info = new FileInfo(path); label_location.Cursor = Cursors.Hand; label_name.Text = info.Name; label_location.Text = info.FullName; label_date_createds.Text = info.CreationTime.ToLongDateString() + " " + info.CreationTime.ToLongTimeString(); label_date_modified.Text = info.LastWriteTime.ToLongDateString() + " " + info.LastWriteTime.ToLongTimeString(); button1.BackgroundImage = ShellIcon.GetLargeIcon(path).ToBitmap(); long size = info.Length; if (size < 1024) { label_size.Text = size.ToString() + "Bytes"; } else if (size < 1048576) { label_size.Text = (((double)size / 1024)).ToString() + "KB"; } else if (size < 1073741824) { label_size.Text = (((double)size / (1024 * 1024))).ToString() + "MB"; } else if (size < 1096290402304) { label_size.Text = (((double)size / (1024 * 1024 * 1024))).ToString() + "GB"; } } else { label_date_createds.Text = ""; label_location.Text = path; label_size.Text = ""; label_name.Text = ""; label_date_modified.Text = ""; button1.BackgroundImage = null; label_location.Cursor = Cursors.Arrow; label_date_createds.ForeColor = Color.Black; label_location.ForeColor = Color.Black; } } catch (Exception ee) { MessageBox.Show(ee.Message); } }