private void UploadPassportbutton_Click(object sender, EventArgs e) { // open file dialog OpenFileDialog getPassport = new OpenFileDialog(); getPassport.Multiselect = false; getPassport.Title = "Select Passport Photograph"; // image filters getPassport.Filter = "Image Files(*.png; *.PNG)|*.png; *.PNG"; if (getPassport.ShowDialog() == DialogResult.OK) { //sets the new file path string newPath = Path.Combine(@"\\QUBE\Pics\", Path.GetFileName(getPassport.FileName)); PassportpictureBox.Image = Image.FromFile(getPassport.FileName); //check if fileexists if (File.Exists(newPath)) { //You could rename the file MessageBox.Show("That image already exists...", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { File.Copy(getPassport.FileName, newPath); } }
File.Move(currentPath, newPath);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)