Can't delete specified file as it is still open in another process ?
i stitching tiff images when try delete images used create combined image unable open in process, i'm trying find out gone wrong in code allow me delete files: code below
private void tiffyfinal() {
list<string> delete = new list<string>();
system.drawing.imaging.encoder encoder1 = system.drawing.imaging.encoder.saveflag; imagecodecinfo encoderinfo1 = imagecodecinfo.getimageencoders().first(i => i.mimetype == "image/tiff"); encoderparameters encoderparameters1 = new encoderparameters(1); encoderparameters1.param[0] = new encoderparameter(encoder1, (long)encodervalue.multiframe); string verbals = configurationsettings.appsettings["verbals"]; string[] fileimagesfinal = directory.getfiles(verbals); //generate bitmap bitmap images binded system.drawing.bitmap firstimagefinal = new system.drawing.bitmap(fileimagesfinal[0]); //saves file file path(textbox2.text) , name of file(textbox3.text) firstimagefinal.save(textbox2.text.tostring() + "\\" + textbox3.text.tostring()+"combine" + ".tif", encoderinfo1, encoderparameters1); encoderparameters1.param[0] = new encoderparameter(encoder1, (long)encodervalue.framedimensionpage); foreach (string imagefinal in fileimagesfinal) { system.drawing.bitmap bitmapfinal = new system.drawing.bitmap(imagefinal); //adds images firstimage multiframe tiff image. firstimagefinal.saveadd(bitmapfinal, encoderparameters1); string filenamewithoutpath = path.getfilename(imagefinal); delete.add(@verbals + filenamewithoutpath); } // clear file in memory holding bitmap image data try { encoderparameters1.param[0] = new encoderparameter(encoder1, (long)encodervalue.flush); } catch (exception error) { messagebox.show(error.message); } foreach (string file in delete) { file.delete(file); } }
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment