I am building an archery app to keep score. I have a folder called ScoreData
reData in which I am writing to a file and storing in. When scoring is finished, I want to write the data to a simple .txt file in said folder. For my windows debugging, it is searching the solution using GetEntryAssembly and going up a folder each time until it finds the ScoreData folder. This solution gives me no errors when debugging using “Windows Machine” but when I hook up my iPhone to debug, it throws errors on the GetDirectories() method.
Here is the current code I have that does work with Windows, but throws errors when debugging on an iOS device.
`var anotherDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
var assembly = typeof(App).GetTypeInfo().Assembly;
//var location = assembly.Location;
//var dirst = Assembly.GetEntryAssembly();
//var dires = Directory.GetDirectories(dirst.ToString());
var directory = new DirectoryInfo(anotherDir ?? Directory.GetCurrentDirectory());
var path = string.Empty;
while (directory != null && !directory.GetFiles("*.sln").Any())
{
directory = directory.Parent;
var folders = directory.GetDirectories();
if (folders.Length == 9)
{
var folder = folders[6];
path = folder.FullName;
}
}
return path;
`
And here is a screenshot of where I am wanting to get the filepath for when debugging in iOS.
enter image description here
Cody Whitaker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.