c# - Why does DotNetZip cause OutOfMemory Exception in Images? -


i have tried zipping .png image file zip file using dotnetzip after extract later on , use image.fromfile method gives me outofmemory exception. have tried other images gives me same result. if override image file wasn't zipped don't error.

compression code

savefiledialog sfd = new savefiledialog(); sfd.filter = system.abriviation + " game|*" + system.extention; sfd.addextension = true; sfd.showdialog();  if (sfd.filename != "") {      streamwriter write = new streamwriter(application.startuppath + "\\meta");     write.writeline(txtname.text);     write.writeline(new fileinfo(txtgame.text).extension);     write.writeline(txtcompany.text);     write.close();      file.copy(txtgame.text, application.startuppath + "\\game" + new fileinfo(txtgame.text).extension);     file.copy(txtgame.text, application.startuppath + "\\icon.png");      zipfile zip = new zipfile();     zip.addfile(application.startuppath + "\\meta", "");     zip.addfile(application.startuppath + "\\game" + new fileinfo(txtgame.text).extension, "");     zip.addfile(application.startuppath + "\\icon.png", "");     zip.save(sfd.filename);     zip.dispose();      file.delete(application.startuppath + "\\game" + new fileinfo(txtgame.text).extension);     file.delete(application.startuppath + "\\icon.png");     file.delete(application.startuppath + "\\meta");      close(); } 

extraction code

zipfile zip = zipfile.read(file); bool foundmeta = false; string id = ""; foreach(zipentry e in zip){     if (e.filename == "meta")     {         e.extract(application.startuppath);         streamreader read = new streamreader(application.startuppath + "\\meta");         id = read.readline();         read.close();         file.delete(application.startuppath + "\\meta");         foundmeta = true;         break;     } }  if (foundmeta) {     if (!gamesystem.exists(id))     {         zip.extractall(main.library.path + "\\" + id.replace(" ", "_").tolower());         directory.createdirectory(main.library.path + "\\" + id.replace(" ", "_").tolower() + "\\games");         directory.createdirectory(main.library.path + "\\" + id.replace(" ", "_").tolower() + "\\games\\metas");     }     else     {         messagebox.show("system " + id + " added.", "8 bit", messageboxbuttons.ok, messageboxicon.error);     } } else {     messagebox.show("could not find meta file.", "8 bit", messageboxbuttons.ok, messageboxicon.error); } zip.dispose();  return gamesystem.load(main.library.path + "\\" + id.replace(" ", "_").tolower()); 

image loading code

string name = "", company = "", ext = ""; fileinfo info = new fileinfo(file); streamreader read = new streamreader(file); name = read.readline(); ext = read.readline(); company = read.readline(); read.close();  image icon = null; if (file.exists(system.gamemetapath + "\\" + info.name + ".png")) {     icon = image.fromfile(system.gamemetapath + "\\" + info.name + ".png");     //the error happens on line above. }  return new game(system, name, company, system.gamepath + "\\" + info.name + ext, file, icon); 

is there way around or fix problem?


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -