Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.IO.IOException_mscorlib.dll File.Move #1

Open
kordokrip opened this issue Mar 20, 2019 · 0 comments
Open

System.IO.IOException_mscorlib.dll File.Move #1

kordokrip opened this issue Mar 20, 2019 · 0 comments

Comments

@kordokrip
Copy link

Hello your program is great.
The current source code looks for similar images and executes the save (copy) function. I am having trouble modifying the source to change the save to the move function.

File.Copy(image_path, copy, false); -> File.Move(image_path, copy, false);
System.IO.IOException_mscorlib.dll
Thanks for your help.

FindSimilarImages.xaml.cs

using (var dlg = new System.Windows.Forms.FolderBrowserDialog())
{
dlg.Description = "Select folder where the images will be saved";
dlg.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

        dlg.ShowNewFolderButton = true;
        var result = dlg.ShowDialog();
        if (result == System.Windows.Forms.DialogResult.OK)
            {
                //save image of interest
                var image_name = Path.GetFileName(image_of_interest);
                var image_path = image_of_interest;
                var copy = Path.Combine(dlg.SelectedPath, image_name);

                

                if (File.Exists(image_path) && !File.Exists(copy))
                    {
                        File.Copy(image_path, copy);
                    }

                //save similar images
                foreach (var image in similar_images)
                    {
                        if (image == null)
                            {
                                continue;
                            }
                        image_name = image.ImageName;
                        image_path = image.ImagePath;

                    copy = Path.Combine(dlg.SelectedPath, image_name);

                    if (File.Exists(image_path) && !File.Exists(copy))
                    {
                        File.Copy(image_path, copy, false);
                    }

                 }
            }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant