예제 #1
0
        public static void DeleteImage(string imagefilename)
        {
            if (!string.IsNullOrEmpty (imagefilename)) {
                string name = imagefilename.Substring (0, imagefilename.Length - 4);
                var documentsDirectory = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
                var picname = name + ".png";
                var thumbpicname = name + "_thumb.png";
                string pngfileName = System.IO.Path.Combine (documentsDirectory, picname);
                string thumbpngfileName = System.IO.Path.Combine (documentsDirectory, thumbpicname);

                NSFileManager fm = new NSFileManager ();

                NSError err = null;

                if (fm.IsDeletableFile (pngfileName)) {
                    fm.Remove (pngfileName, out err);
                    //TODO use error for something sensible
                }

                err = null;

                if (fm.IsDeletableFile (thumbpngfileName)) {
                    fm.Remove (thumbpngfileName, out err);
                    //TODO use errormsg for something sensible.
                }
            }
        }