Example #1
0
 public void DeleteShip(String inpShip)
 {
     try
     {
         var path = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/files/" + inpShip + "/";
         var dir  = new Java.IO.File(path);
         // System.Diagnostics.Debug.WriteLine("***** DeleteShip: directory exists: " + dir.Exists());
         if (dir.Exists())
         {   // Android Java Unix command will delete the whole ship directory which includes all reports
             String            deleteCmd = "rm -r " + path;
             Java.Lang.Runtime runtime   = Java.Lang.Runtime.GetRuntime();
             try
             {
                 runtime.Exec(deleteCmd);
             }
             catch (IOException e)
             {
                 System.Diagnostics.Debug.WriteLine("***** DeleteShip rm -r threw exception: " + e.ToString());
             }
         }
         // dir.Delete();
         var fileP = new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath
                                      + "/files/" + inpShip + "_config.xml");
         fileP.Delete();
         fileP = new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath
                                  + "/files/" + inpShip + "_graphic.png");
         fileP.Delete();
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine("***** DeleteShip failed: " + e.ToString());
     }
 }
Example #2
0
        public void DeleteReport(String inpReportPath)
        {
            var path = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/files/" + inpReportPath + "/";
            var dir  = new Java.IO.File(path);

            // System.Diagnostics.Debug.WriteLine("***** DeleteReport: directory exists: " + dir.Exists());
            if (dir.Exists())
            {   // Android Java Unix command will delete the whole report directory
                String            deleteCmd = "rm -r " + path;
                Java.Lang.Runtime runtime   = Java.Lang.Runtime.GetRuntime();
                try
                {
                    runtime.Exec(deleteCmd);
                    while (dir.Exists())
                    {
                        // System.Diagnostics.Debug.WriteLine("***** Waiting for directory deletion");
                    }
                }
                catch (IOException e)
                {
                    System.Diagnostics.Debug.WriteLine("***** DeleteReport rm -r threw exception: " + e.ToString());
                }
            }
        }