TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mayank Jani
NA
477
77.4k
Error: the file is being used by another process.
Aug 8 2019 8:52 AM
Hiii members,
I am working on a WinApp in C#. In a WinForm, I have a ListView and a PictureBox. When the form gets load, the ListView fetches all the pictures from a perticular folder and shows them as thumbnail.
When I click on any thumbnail, the selected image loads into the PictureBox. Now, there is a 'Delete' button, when I click the button to delete the selected image from the folder, it throws and error... 'it is being used by another process.'
If it is because using by the PictureBox then I have emptied the PictureBox but error remain, then I do not know about the ListView or what is the 'another process'
Please help.
Thank You.
Mayank Jani
My code...
var index = lvThumbs.SelectedItems[0].Index; //This code fetches
pbImage.Image = Image.FromFile(_files[index].FullName); //the image file location
pbImage.ImageLocation = _files[index].FullName; //to delete the image file from a folder.
//MessageBox.Show("Deleting Path -> " + pbImage.ImageLocation); //This message box shows actual path and file name.
pbImage.Image = null;
File.Delete(pbImage.ImageLocation); //Here I got error, "it is being used by another process...".
MessageBox.Show("Deleted.");
Reply
Answers (
5
)
Save/export the datagridview contents
How To send Whatsapp Message in C#