Ich bin eine Stackoverflow während der Laufzeit immer, ich bin sicher, dass ich zu viele Methoden nenne, kann einfach nicht erkennen, wo dies geschieht. Wenn ich das Programm laufen tritt die Ausnahme, wenn die Parameter Struktur Variable deklariert wird.C# Stackoverflow, Zu viele Methodenaufrufe
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() von einer anderen Klasse wird wie so genannt. Dies ist der einzige Hinweis auf FolderContentManagement, die diese Klasse hat.
contents[1] = String.Format("ligand = {0}", fcm.GetCurrentStructurePath());
Jede Hilfe würde sehr geschätzt werden.
Ich schlage vor, einen _break_ hinzuzufügen, wenn Sie die Datei in _GetCurrentStructurePath_ – Steve
gesucht finden Um genau zu sein, ist dies die Zeile, die die Ausnahme aufwirft private String structurePath = Path.Combine (Directory.GetCurrentDirectory(), "Strukturen"); ' –
Stackoverflows treten normalerweise auf, wenn Sie eine unendlich rekursive Funktion haben. – Krythic