Hi,
i want to detect an USB or SD Drive by it´s name. Because it is always the same name but may be on another COM-Port. I need to copy files from it, to it and delete files from it (that i already know) but i dont know how to detect the SD-Card at all..
Is there an easy solution for it?
The actual code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Management;
using System.Runtime.InteropServices;
namespace Evatec_Update_Installer
{
public partial class Step7Screen : Form
{
public Step7Screen()
{
InitializeComponent();
}
private void Step7Screen_Load(object sender, EventArgs e)
{
}
private void FormNext_Click_1(object sender, EventArgs e)
{
this.Hide();
Step8Screen sF = new Step8Screen();
sF.Show();
}
private void BTNStartUpdate_Click(object sender, EventArgs e)
{
//FormBack.Enabled = false;
button1.Enabled = false;
}
private void button1_Click(object sender, EventArgs e)
{
//FormBack.Enabled = false;
groupBox1.Visible = true;
groupBox1.Enabled = true;
}
private void FormClose_Click(object sender, EventArgs e)
{
System.Windows.Forms.Application.Exit();
}
private void Step7Screen_FormClosing(object sender, FormClosingEventArgs e)
{
System.Windows.Forms.Application.Exit();
}
private void FormBack_Click(object sender, EventArgs e)
{
this.Hide();
Step6Screen sF = new Step6Screen();
sF.Show();
}
private void button22_Click(object sender, EventArgs e)
{
pictureBox2.Visible = true;
button22.Enabled = false;
progressBar2.Visible = true;
label8.Visible = true;
label8.ForeColor = System.Drawing.Color.Blue;
label8.Text = "Please insert Safety SD-Card...";
progressBar2.Value = 4;
label8.ForeColor = System.Drawing.Color.Orange;
label8.Text = "Safety SD-Card detecting...";
progressBar2.Value = 8;
label8.ForeColor = System.Drawing.Color.Black;
label8.Text = "Safety SD-Card detected...";
progressBar2.Value = 12;
label8.ForeColor = System.Drawing.Color.Orange;
label8.Text = "Safety SD-Card backing up...";
progressBar2.Value = 16;
label8.ForeColor = System.Drawing.Color.Green;
label8.Text = "Safety SD-Card backed up...";
progressBar2.Value = 20;
label8.ForeColor = System.Drawing.Color.Orange;
label8.Text = "Safety SD-Card deleting files...";
progressBar2.Value = 24;
label8.ForeColor = System.Drawing.Color.Green;
label8.Text = "Safety SD-Card files deleted...";
progressBar2.Value = 28;
label8.ForeColor = System.Drawing.Color.Orange;
label8.Text = "Safety SD-Card copying new files...";
progressBar2.Value = 32;
label8.ForeColor = System.Drawing.Color.Green;
label8.Text = "Safety SD-Card new files copied...";
progressBar2.Value = 36;
label8.ForeColor = System.Drawing.Color.Blue;
label8.Text = "Please remove Safety SD-Card...";
progressBar2.Value = 40;
label8.ForeColor = System.Drawing.Color.Black;
label8.Text = "Safety SD-Card removed...";
progressBar2.Value = 45;
label8.ForeColor = System.Drawing.Color.Green;
label8.Text = "Safety SD-Card updated";
progressBar2.Value = 50;
label9.Visible = true;
label9.ForeColor = System.Drawing.Color.Blue;
label9.Text = "Please insert Standard SD-Card...";
progressBar2.Value = 54;
label9.ForeColor = System.Drawing.Color.Orange;
label9.Text = "Standard SD-Card detecting...";
progressBar2.Value = 58;
label9.ForeColor = System.Drawing.Color.Black;
label9.Text = "Standard SD-Card detected...";
progressBar2.Value = 62;
label9.ForeColor = System.Drawing.Color.Orange;
label9.Text = "Standard SD-Card backing up...";
progressBar2.Value = 66;
label9.ForeColor = System.Drawing.Color.Green;
label9.Text = "Standard SD-Card backed up...";
progressBar2.Value = 70;
label9.ForeColor = System.Drawing.Color.Orange;
label9.Text = "Standard SD-Card deleting files...";
progressBar2.Value = 74;
label9.ForeColor = System.Drawing.Color.Green;
label9.Text = "Standard SD-Card files deleted...";
progressBar2.Value = 78;
label9.ForeColor = System.Drawing.Color.Orange;
label9.Text = "Standard SD-Card copying new files...";
progressBar2.Value = 82;
label9.ForeColor = System.Drawing.Color.Green;
label9.Text = "Standard SD-Card new files copied...";
progressBar2.Value = 86;
label9.ForeColor = System.Drawing.Color.Blue;
label9.Text = "Please remove Standard SD-Card...";
progressBar2.Value = 90;
label9.ForeColor = System.Drawing.Color.Black;
label9.Text = "Standard SD-Card removed...";
progressBar2.Value = 95;
label9.ForeColor = System.Drawing.Color.Green;
label9.Text = "Standard SD-Card updated";
progressBar2.Value = 100;
pictureBox2.Visible = false;
progressBar2.Enabled = false;
}