String  getFileName(String fileName,int inc) {
		if (ctrl) {
			if (fileName.indexOf("c:")==0) {fileName="/home/robm"+fileName.substring(2);} 
			else if (fileName.indexOf("/home/robm")==0) {fileName="c:"+fileName.substring(9);} 
			return fileName;
		}
		String fileNameBack=fileName.trim();
		if (!isUnix) { fileNameBack=fileName.replaceAll("/","\\\\");}
		File f=new File(fileNameBack);
		File parent=null;
		File[] dirList;
		String lastFragmet="";
		if (f.exists()) {
			//f ile exists
			if (f.isDirectory()) {
				if (fileNameBack.endsWith(File.separator)) {parent=f;	}
				else {parent=f.getParentFile();}
			}
			else {parent=f.getParentFile();}
		}else {
			//file doesnt exist.
			int pos=fileNameBack.lastIndexOf(File.separator);
			String testFileName="";
			//if there is a \ in the srting then take all up to the and assume its a diectory. 
			if (pos>0) {testFileName=fileNameBack.substring(0,pos);}
			else {return fileName;}
			if (testFileName.length()>0) {
				f=new File(testFileName);
				if (f.exists()) {parent =f;} 
				lastFragmet=fileNameBack.substring(pos+1,fileNameBack.length());
			}
		}
		if (parent==null) {return fileName;}
		dirList =parent.listFiles();
		// sort the list.
		List listSort=new ArrayList();
		for (int i=0;i<dirList.length;i++) {listSort.add(dirList[i]);}
		Collections.sort(listSort,new FileComparator());
		for (int i=0;i<dirList.length;i++) {dirList[i]=(File)listSort.get(i);}
		// the return file.
		String returnFile="";
		for (int i=0;i<dirList.length;i++) {
			if (fileNameBack.equals(dirList[i].getAbsolutePath())) {
				if (inc==1) {// next file.
					if (i<dirList.length-1) {returnFile= dirList[i+1].getAbsolutePath();} 
					else {returnFile=dirList[0].getAbsolutePath();}
				}
				else if (inc==-1) {// last file.
					if (i>1) {returnFile= dirList[i-1].getAbsolutePath();} 
					else {returnFile= dirList[dirList.length-1].getAbsolutePath();}
				}
			}
		}
		if ("".equals(returnFile)) {
			if (dirList.length>0) { 
				// check if there is a remaining fragmet and find the first file with the same first  letter.
				if (!"".equals(lastFragmet)) { 
					for (int i=0;i<dirList.length;i++) {
						if (dirList[i].getName().startsWith(""+lastFragmet.charAt(0))) {returnFile= dirList[i].getAbsolutePath();}
					}
					if ("".equals(returnFile)) {returnFile=dirList[0].getAbsolutePath();}
				}
				else {returnFile=dirList[0].getAbsolutePath();}// no fragment just return the first file.
			}
		}
		if ("".equals(returnFile)) {return fileName;}// nothing found. just return the original string.
		else if (!isUnix) {return returnFile.replaceAll("\\\\", "/");}
		else {return returnFile;}
	}