I am getting a StackOverflowException during run time, I'm sure that I am calling too many methods, just can't pinpoint where this is happening. When I run the program the Exception occurs when the structurePath variable is declared.
FolderContentManagement.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace VINA_BATCH.FFManagement
{
class FolderContentManager : FileContentManager
{
public int currIndex = 0;
private VinaProcess.VProcess vproc = new VinaProcess.VProcess();
private string structurePath = Path.Combine(Directory.GetCurrentDirectory(), "structures");
private string structureExt = "*.pdbqt";
private Dictionary<string, string> files = new Dictionary<string, string>();
public FolderContentManager() { }
//Returns list of structures
public string[] GetStructuresPath()
{
return Directory.GetFiles(structurePath, structureExt);
}
public string[] GetStructureNames()
{
string[] structs = Directory.GetFiles(structurePath, structureExt);
for(int i = 0; i < structs.Length; i++)
{
structs[i] = Path.GetFileName(structs[i]);
}
return structs;
}
public string GetCurrentStructureName()
{
string currPath = this.GetCurrentStructurePath();
return Path.GetFileName(currPath);
}
public string GetCurrentStructurePath()
{
string currPath = "";
string[] paths = Directory.GetFiles(structurePath, structureExt);
for (int i = 0; i < paths.Length; i++)
{
if (i == currIndex)
currPath = paths[i];
}
return currPath;
}
public string GetNextStructurePath(int index)
{
string[] names = GetStructureNames();
string[] paths = GetStructuresPath();
string nextPath = "";
for (int i = 0; i < names.Length; i++)
{
if (i == index)
nextPath = paths[index + 1];
}
return nextPath;
}
/*
public void CompilePathsFiles()
{
string workingPath = GetWorkingPath();
string[] tempFiles = { GetCurrentStructureName(), findProtein(), "conf.txt", "log.txt" };
for(int i = 0; i < tempFiles.Length; i++)
{
if (i == 0)
files.Add(structurePath, tempFiles[i]);
files.Add(workingPath, tempFiles[i]);
}
MessageBox.Show(files.ToString());
}
*/
public void Move_RunRoutine()
{
/*
- After conf.txt change copy to vina folder
- Copy the rest of the working folder file to vina folder
- Copy the current *.pdbqt file to the vina folder
*/
string destination = vproc.GetVinaPath();
}
public void Move_OutRoutine()
{
/*
- Once an iteration is done move the contents of the vina folder to out folder with the name of the *.pdbqt file
*/
}
}
}
GetCurrentStructurePath() is being called from another class like so. This is the only reference to FolderContentManagement that this class has.
contents[1] = String.Format("ligand = {0}", fcm.GetCurrentStructurePath());
Any help would be much appreciated.