Hi

          Are you creating multiple Threads to call saveBMP, In that
case only you will see this type of jumping in code?

Best Regards,
Sridharan Srinivasan
Alias Sri.

On Fri, Sep 23, 2011 at 6:57 PM, John Murray <j...@murray.gb.com> wrote:
> I cant understand what’s going on here
>
> In MonoDevelop I just get an unhandled exception
>
> In Vis studio I get more of a clue as it says there’s a sharing violation
>
>
>
> Weirdly stepping through in the debugger it seems to go round the loop twice
> (i.e. it steps down to Bitmap.compress then springs back to the File.Exists
> line and steps through it again
>
> hence one can understand that if the stream is already open there may be a
> sharing issue
>
> But why does it go round twice?  It gets to the line Bitmap.Compress() then
> loops back to File.Exists();
>
> If I remove the File.Exists code then it crashes out at Bitmap.Compress with
> the contradictory message
>
> “System.IO.IOException: Win32 IO returned ERROR_SUCCESS”
>
>
>
> If the File.Exists code is left in I get a sharing violation when it gets to
> the Fielstream line
>
> Presumably because FS is still open having already run through that code
> once before.
>
> What is going on – why does it suddenly decide to revisit the earlier lines
> of code? Or run through a line of code twice?
>
>
>
>
>
> public static void saveBMP(Context cntxt,string filename)
>
>         {
>
>             if (File.Exists(filename))     // shouldn't have to do this if
> FileShare.Delete is working as I understand it
>
>             {
>
>                 File.Delete(filename);      // on second loop around it
> deletes file but then there is an error with file does not exist
>
>             }
>
>
>
>             FileStream fs = new FileStream(filename, FileMode.Create,
> FileAccess.Write, FileShare.Delete);
>
>             System.IO.BufferedStream buf = new System.IO.BufferedStream(fs);
>
>             Bitmap bmp = WXclass5.windmap;
>
>             bmp.Compress(Bitmap.CompressFormat.Png, 90, buf);
>
>             fs.Close();
>
>             buf.Close();
>
>             bmp = null;
>
>             //fout.Close();
>
>             WXclass5.pnglist = getlistpngs(cntxt);
>
>         }
>
>
>
>
>
> _______________________________________________
> Monodroid mailing list
> Monodroid@lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
>



-- 
Sridharan Srinivasan
Alias Sri
Ph:(65)98255785/(65)63922439
www.arshu.com
_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to