Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem in arcgis c#. I am using Arcgis axMapControl component and adding image to it but I can not delete image when wanted to delete from axMapControl component... I have get a exception such as " The process cannot access the file C:\Users.. because it is being used by another process "

Thanks for your help.

public void Add_map()

  IRasterLayer my_raster = new RasterLayer();
public void Delete_map()

System.IO.File.delete(path);    //There is a Exception.... This problem...
share|improve this question

You cannot directly delete the raster, since your application still has references to it. What you need to do, is to delete all references you are holding to it in code, and then delete it using lower level ArcObjects: IDataset:Delete

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.