16-11-17, 02:12 PM
عندى gridview به عمود واحد يعرض صور مخزنه بقاعده البيانات
اريد حفظ كل الصور من gridview فى مسار معين واعطاء اسماء تلقائيه لكل صوره وحفظها فى المسار المحدد
وشكرا على كل حال
If f3.dgw.Rows.Count > 0 And fbdPicture.ShowDialog <> DialogResult.Cancel Then
Dim spath As String = "" Dim fpath As String = fbdPicture.SelectedPath Dim makepath As String = "0" Dim makefullpath As String For Each row As DataGridViewRow In f3.dgw.Rows If Not row.IsNewRow Then Dim ms As New MemoryStream() Dim img As Image = row.Cells(0).Value Dim bmpImage As New Bitmap(img) bmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg) makepath += 1 makefullpath = String.Format("{0} ({1})", f3.txtProductCode.Text, makepath) spath = String.Format("{0}\{1}", fpath, makefullpath) Picture.Image = bmpImage If cmbFormats.SelectedItem = "BMP" Then Picture.Image.Save(spath & ".bmp", System.Drawing.Imaging.ImageFormat.Bmp) If cmbFormats.SelectedItem = "PNG" Then Picture.Image.Save(spath & ".png", System.Drawing.Imaging.ImageFormat.Png) If cmbFormats.SelectedItem = "GIF" Then Picture.Image.Save(spath & ".gif", System.Drawing.Imaging.ImageFormat.Gif) If cmbFormats.SelectedItem = "TIFF" Then Picture.Image.Save(spath & ".tiff", System.Drawing.Imaging.ImageFormat.Tiff) If cmbFormats.SelectedItem = "JPG" Then Picture.Image.Save(spath & ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg) spath = "" End If NextIf f3.dgw.Rows.Count > 0 And fbdPicture.ShowDialog <> DialogResult.Cancel Then
Dim spath As String = ""
Dim fpath As String = fbdPicture.SelectedPath
Dim makepath As String = "0"
Dim makefullpath As String
For Each row As DataGridViewRow In f3.dgw.Rows
If Not row.IsNewRow Then
Dim ms As New MemoryStream()
Dim img As Image = row.Cells(0).Value
Dim bmpImage As New Bitmap(img)
bmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
makepath += 1
makefullpath = String.Format("{0} ({1})", f3.txtProductCode.Text, makepath)
spath = String.Format("{0}\{1}", fpath, makefullpath)
Picture.Image = bmpImage
If cmbFormats.SelectedItem = "BMP" Then Picture.Image.Save(spath & ".bmp", System.Drawing.Imaging.ImageFormat.Bmp)
If cmbFormats.SelectedItem = "PNG" Then Picture.Image.Save(spath & ".png", System.Drawing.Imaging.ImageFormat.Png)
If cmbFormats.SelectedItem = "GIF" Then Picture.Image.Save(spath & ".gif", System.Drawing.Imaging.ImageFormat.Gif)
If cmbFormats.SelectedItem = "TIFF" Then Picture.Image.Save(spath & ".tiff", System.Drawing.Imaging.ImageFormat.Tiff)
If cmbFormats.SelectedItem = "JPG" Then Picture.Image.Save(spath & ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
spath = ""
End If
Next