Thanks for responding.
Here is a very simplified barebones version of my image viewer/copier program
It has one PictureBox, four Button, and two FolderBrowserDialog.
Imports System.IO
Public Class Form1
Dim FromFolder As String
Dim ToFolder As String
Dim ImageFiles() As String
Dim ImageFilesCount As Integer
Dim Index As Integer
Dim CurrentImage As String
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'establish From and To folders
FromFolder = Directory.GetCurrentDirectory
ToFolder = Directory.GetCurrentDirectory
ImageFinder()
ImageLoader()
End Sub
Private Sub ImageFinder()
'find images in the From folder and place them in an array
Dim AllowedExtensions() As String = {".bmp", ".gif", ".jpe", ".jpg", ".jpeg", ".png", ".tif"}
Dim AllFiles() As String = Directory.GetFiles(FromFolder, "*.*")
Dim MyArrayList As New ArrayList
For Each File As String In AllFiles
For Each AllowedExtension As String In AllowedExtensions
If AllowedExtension = Path.GetExtension(File).ToLower Then
MyArrayList.Add(File)
End If
Next
Next
ImageFiles = MyArrayList.ToArray(GetType(String))
End Sub
Private Sub ImageLoader()
'load an image into the picture box
ImageFilesCount = ImageFiles.Length
If ImageFilesCount > 0 Then
PictureBox1.Load(ImageFiles(Index))
CurrentImage = Path.GetFileName(ImageFiles(Index))
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'choose a different From folder
FolderBrowserDialog1.SelectedPath = FromFolder
If (FolderBrowserDialog1.ShowDialog() = DialogResult.OK) Then
FromFolder = FolderBrowserDialog1.SelectedPath
ImageFinder()
ImageLoader()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'choose a To folder
FolderBrowserDialog2.SelectedPath = ToFolder
If (FolderBrowserDialog2.ShowDialog() = DialogResult.OK) Then
ToFolder = FolderBrowserDialog2.SelectedPath
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'flip through images in the From folder
If ImageFilesCount > 0 Then
If Index > 0 Then
Index -= 1
ImageLoader()
Else
Index = ImageFilesCount - 1
ImageLoader()
End If
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
'copy CurrentImage from From folder to To folder
If ImageFilesCount > 0 Then
Try
File.Copy(CurrentImage, (ToFolder + "\" + CurrentImage), False)
MsgBox(CurrentImage & " copied successfully")
Catch ex As Exception
MsgBox(CurrentImage & " not copied (or may already exists in this folder)")
End Try
End If
End Sub
End Class
Works fine in debug mode. I built it, published it to the desktop, and ran setup. It will browse images etc. fine, but not allow me to copy.
Thanks for any help.