Question: I have seen other post but can't seem to put it well in my post. Could someone help me with this.i am able to view the files and open them but need them to list from the recent create to oldest. Below is my code. 

```
    private List<String> fileList = new ArrayList<String>();

    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

   String root = Environment.getExternalStoragePublicDirectory("/MyAppFolder").
            getAbsolutePath();
    // ListDir(root);

    pdf = new File(root);
    ListDir(pdf);
   }

    void ListDir(File f) {
    File[] files = f.listFiles();
    fileList.clear();

    for (File file : files) {

        fileList.add(file.getName());

    }

    ArrayAdapter<String> directoryList = new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_1, fileList);

    setListAdapter(directoryList);

  }

  public void onListItemClick(ListView parent, View v, int position, long id) {
    //selection.setText(fileList.indexOf(simple_list_item_1));
    OpenPdf(fileList.get(position).toString());
  }

  public void OpenPdf(String path)
  {
      File file = new File(path);
      if (file.exists()) {
          Uri p = Uri.fromFile(file);
          Intent intent = new Intent(Intent.ACTION_VIEW);
          intent.setDataAndType(p, "application/pdf");
          intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

          try {
              startActivity(intent);
          } 
          catch (ActivityNotFoundException e){
          }
      }
  }
}

```

Answer: 
Your main concern is performance. If you copy field-by-field, this will translate to 6 `mov` instructions. It is very hard to make it faster then this.

Using pointers does not reduce the number of instructions required. Why would it? You still need the same assignments.

Calling `memcpy` involves far more overhead then the trivial 6 `mov` instructions.

So you should write the "naive" three assignments using safe managed code to get optimal performance. In fact, copying this 12-byte object is so cheap that I doubt your performance concerns are valid. I doubt this will show up on any profile.

For copy performance it does not matter whether you use `class` or `struct`. But `struct` has certain performance benefits due to other differences. You might want to investigate them.
If both structs have same layout you can just cast pointer and assign like this:

```
var a1 = new Dto { B = 10, C = 20, D = 30 };
var a2 = new Model();

unsafe
{
     fixed (Dto * pa1 = &(a1))
     {
          fixed (Model* pa2 = &(a2))
          {
               *pa2 = *(Model*)pa1;
          }
     }
 }

```