views:

81

answers:

1

Hi there,

the swt file dialog will give me an empty result array if I select too much files (approx. >2500files). The listing shows you how I use this dialog. If i select too many sound files, the syso will show 0. Debugging tells me, that the files array is empty in this case. Is there any way to get this work?

FileDialog fileDialog = new FileDialog(mainView.getShell(), SWT.MULTI);
  fileDialog.setText("Choose sound files");
  fileDialog.setFilterExtensions(new String[] { new String("*.wav") });
  Vector<String> result = new Vector<String>();
  fileDialog.open();

  String[] files = fileDialog.getFileNames();
  for (int i = 0, n = files.length; i < n; i++) {
   if( !files[i].contains(".wav")) {
    System.out.println(files[i]);
   }

   StringBuffer stringBuffer = new StringBuffer();
   stringBuffer.append(fileDialog.getFilterPath());
   if (stringBuffer.charAt(stringBuffer.length() - 1) != File.separatorChar) {
    stringBuffer.append(File.separatorChar);
   }
   stringBuffer.append(files[i]);
   stringBuffer.append("");

   String finalName = stringBuffer.toString();
   if( !finalName.contains(".wav")) {
    System.out.println(finalName);
   }
   result.add(finalName);
  }
  System.out.println(result.size())

;

A: 

I've looked at the FileDialog source code and I'm afraid, there is an upper boundary. A 32kB byte buffer for all 0-terminated filenames (if I understood it correctly).

So calculating with your values, if the medium size of your filname strings is around 12 characters, then you've hit exactly that upper boundary.

So the only way out is to select the files in two or more steps.

Andreas_D
Oh no! ;) Thank you for taking the time.
InsertNickHere