OpenFileDialog opfd = new OpenFileDialog(); opfd.Filter = "JPEG (*.jpg)|*.jpg|Windows bitmap (*.bmp)|*.bmp|All files|*.*"; opfd.InitialDirectory = "C:"; opfd.Title = "Select a picture"; if (opfd.ShowDialog() == DialogResult.OK) { string filenname = System.IO.Path.GetFileName(opfd.FileName); string last = Path.GetExtension(filenname); string path = System.IO.Path.GetDirectoryName(opfd.FileName); this.pictureBox1.Image = new Bitmap(opfd.FileName.ToString()); MessageBox.Show(filenname, path); string sourceFile = path + "/" + filenname; string pathPicture = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Picture"; string destFile = pathPicture + "\\" + label23.Text + last; if (!Directory.Exists(pathPicture)) { Directory.CreateDirectory(pathPicture); } File.Delete(destFile); if (!File.Exists(destFile)) { File.Copy(sourceFile, destFile); MessageBox.Show("บันทึกข้อมูลเรียบร้อย", "ผลการบันทุกข้อมูล", MessageBoxButtons.OK, MessageBoxIcon.Information); }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง