windows phone 7 - Unable to create folder and display Image using WP7 Emulator -
i new wp7 development trying simple example ie..
i have image control , 2 buttons 1 loading image , displaying in image control , other saving image new folder need create.
i have below code , not getting errors problem unable create directory , save existed image folder.
i unable see directory image after saving it.
can see folder in emulator(or)it possible can see created directory on windows phone?
imports system.io imports microsoft.phone.tasks imports system.io.isolatedstorage imports system.windows.media.imaging partial public class page1 inherits phoneapplicationpage public sub new() initializecomponent() photochoosertask = new photochoosertask() addhandler photochoosertask.completed, addressof photochoosertask_completed end sub dim photochoosertask photochoosertask private sub photochoosertask_completed(sender object, e photoresult) dim bmp system.windows.media.imaging.bitmapimage = new system.windows.media.imaging.bitmapimage() bmp.setsource(e.chosenphoto) image1.source = bmp dim originalfilename = path.getfilename(e.originalfilename) saveimage(e.chosenphoto, originalfilename, 0, 100) end sub public shared sub saveimage(byval imagestream stream, byval filename string, byval orientation integer, byval quality integer) using isolatedstorage = isolatedstoragefile.getuserstoreforapplication() if isolatedstorage.fileexists("newpics\filename") isolatedstorage.deletefile("newpics\filename") end if if not isolatedstorage.directoryexists("newpics") isolatedstorage.createdirectory("newpics") end if 'isolatedstorage.createdirectory("newpics") 'dim filestream new isolatedstoragefilestream("filename", filemode.create, isolatedstorage) dim filestream = isolatedstorage.createfile("newpics\" + filename) dim bitmap = new bitmapimage() bitmap.setsource(imagestream) dim wb = new writeablebitmap(bitmap) wb.savejpeg(filestream, wb.pixelwidth, wb.pixelheight, orientation, quality) filestream.close() end using end sub private sub button1_click(sender object, e system.windows.routedeventargs) handles button1.click try photochoosertask.show() catch ex system.invalidoperationexception messagebox.show("an error occurred.") end try end sub end class
can me making mistake?
the code perfect, problem silverlight uses "isolated storage" storing files, is, name implies, isolated storage. file or directory created application accessible application.
i think emulator storing isolated storage files in memory, since doesn't have keep them after restart. if want see inside application's isolated storage use tool wp7 explorer: http://wp7explorer.codeplex.com/
Comments
Post a Comment