c# - The process cannot access the file ' ' because it is being used by another process -
I am trying to delete the local copy of an uploaded image file (on the computer) using the file dialog I am It throws the process 'C: \ Documents and Settings \ user names \ My document \ My Pictures \ 1220.bmp' because it is being used by another process.
Private Zero _btnImportPhoto_Click (Object Sender, RoutedEventArgs e) {// user clicked Import / Change photo, open file dialog for browsing for photo system. Windows.form. OpenFile Dialog file dialeg = new system.windows.form. OpenFile Dialog (); FileDialog.Multiselect = false; FileDialog.filter = ResourceFile.PhotoFileTypes; If (fileDialog.ShowDialog () == System.Windows.Forms.DialogResult.OK) {FilePath = fileDialog.FileName; FilePathCopy = fileDialog.FileName; String SecureFilePath = FilesyLog .SafeFileName; Bitmap bitmap = new bitmap (file path); Current photo = bitmap; Bitmap bitmap 1 = new bitmap (filecapcap); // When a local copy is removed to save a copy, m_PhotoCopy = bitmap1; FileSystem.DeleteFile (FilePath); } _btnSave.IsEnabled = _btnCancel.IsEnabled = true; }} Please tell me how to work around this problem. Thank you.
You need to resolve the bitmap object Try doing this as it will settle the bitmap object, As soon as it uses the context {}
(bitmap bitmap 1 = new bitmap) (// all bitmap content here)
Comments
Post a Comment