I have code with the desired result that I want ( written in Java), but I am unable to convert it to Visual Basic.
What I marked in red text is what I would I like to understand and be able to utilize in Visual Basic. The creation of file objects and utilizing file methods.
What I marked in red text is what I would I like to understand and be able to utilize in Visual Basic. The creation of file objects and utilizing file methods.
Code:
public class FileChanger {
public static void main (String [] args){
String path = "C:/LeagueSongs/";
String files;
FileChanger exists = new FileChanger();
String champSelect = "ChampSelect";
File folder = new File(path);
File[] listOfFiles = folder.listFiles();
boolean success = false;
String[] namePermStored = new String[5];
try{
FileNotFoundException e = new FileNotFoundException();
NullPointerException ex = new NullPointerException();
System.out.println("Checking files in Directory: C:/LeagueSongs/");
String[] nameStored = new String[listOfFiles.length];
if(listOfFiles.length >=1 && listOfFiles.length < 5 ){
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile())
{
files = listOfFiles[i].getName();
nameStored[i] = listOfFiles[i].getName();
namePermStored[i] = nameStored[i];
System.out.println(path + files);
}//end if loop
else
System.out.println(listOfFiles[i].getName() + " is not a file");
}//end for loop
}//end outer-if
else
throw(e);
}//end tryblock
catch(FileNotFoundException e){
System.out.println("Exception: FileNotFoundException");
System.out.println("Place mp3 files only in to the required directory");
}
catch(NullPointerException ex){
System.out.println("C:/LeagueSongs does not exist...Creating file");
success = ( new File("C:/LeagueSongs")).mkdirs();
if(!success){
System.out.println("Directory creation failed");
System.exit(0);
}
else
System.out.println("Directory creation succeeded");
System.exit(0);
}