fisherboy998
New member
- Joined
- May 17, 2013
- Messages
- 4
- Programming Experience
- Beginner
Good afternoon everyone
I'm working on a program that converts images, and it works fine.
I'm currently working on a piece of code that tells what to do when the file already exists.
The situation:I got the converting system in the main form (form1),
then i got a second form (instellingen) in which you can set preferences/settings.
But the user can select 8 different type of extensions to convert to (.jpeg, .bmp, .gif, etc...)
so if I would use the following piece of code i have to set it for every extension seperately...
everything works well but i'm currently wondering if there's a more efficient way to use the following piece of code:
(it's just about the part that tells you what to do when the file exists, the rest is to clear things up a little)
I'm working on a program that converts images, and it works fine.
I'm currently working on a piece of code that tells what to do when the file already exists.
The situation:I got the converting system in the main form (form1),
then i got a second form (instellingen) in which you can set preferences/settings.
But the user can select 8 different type of extensions to convert to (.jpeg, .bmp, .gif, etc...)
so if I would use the following piece of code i have to set it for every extension seperately...
everything works well but i'm currently wondering if there's a more efficient way to use the following piece of code:
(it's just about the part that tells you what to do when the file exists, the rest is to clear things up a little)
'Count items in list to convert' For Each item As ListViewItem In ListView1.Items 'Convert size' Dim original As Image = Image.FromFile(item.Text & "\" & item.SubItems(1).Text & item.SubItems(2).Text) Dim newbmp As New Bitmap(original, TextBox1.Text, TextBox2.Text) Dim gp As Graphics = Graphics.FromImage(newbmp) 'Save the file Dim strfilename As String 'Count how many files are in the directory Dim counter = My.Computer.FileSystem.GetFiles(TextBox3.Text) Dim intCount As Integer intCount = CStr(counter.Count) If Instellingen.RadioButton1.Checked = True Then If ComboBox1.SelectedItem = ".Jpeg" Then strfilename = "afbeelding" & intCount + 1 If File.Exists(TextBox3.Text & "\" & strfilename & ".Jpeg") = True Then If Instellingen.RadioButton3.Checked = True Then strfilename = "afbeelding" & intCount + 1 & "(2)" newbmp.Save(TextBox3.Text & "\" & strfilename & ".Jpeg", System.Drawing.Imaging.ImageFormat.Jpeg) ElseIf Instellingen.RadioButton4.Checked = True Then newbmp.Save(TextBox3.Text & "\" & strfilename & ".Jpeg", System.Drawing.Imaging.ImageFormat.Jpeg) ElseIf Instellingen.RadioButton5.Checked = True Then End If ElseIf File.Exists(TextBox3.Text & "\" & strfilename & ".Jpeg") = False Then newbmp.Save(TextBox3.Text & "\" & strfilename & ".Jpeg", System.Drawing.Imaging.ImageFormat.Jpeg) End If
Last edited by a moderator: