I just installed Iron Python. When I open it up in terminal it shows installed. When I look for the .dll in Visual Studio I can find them an add them to the project. I was following along a tutorial on microsoft site. Everything was going fine until I got to the very end with...
Save the file and press CTRL+F5 to build and run the application.
Which is when I got the error.
Unhandled Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Program >Files (x86)\IronPython 2.7.9 for .NET 4.0\Lib'. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.Directory.SetCurrentDirectory(String path) at DynamicIronPythonSample.Program.Main() in >C:\Users\scott\source\repos\DynamicIronPythonSample\Program.cs:line 17
This is what I am referencing Walkthrough: Creating and Using Dynamic Objects (C# and Visual Basic)
How can I fix this issue? Line 17 is this line in Program.cs
System.IO.Directory.SetCurrentDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + @"\IronPython 2.7.9 for .NET 4.0\Lib");
Entire script
using Microsoft.Scripting.Hosting;
using IronPython.Hosting;
using System;
using System.Linq;
namespace DynamicIronPythonSample
{
class Program
{
static void Main()
{
// Set the current directory to the IronPython libraries.
System.IO.Directory.SetCurrentDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + @"\IronPython 2.7.9 for .NET 4.0\Lib");
// Create an instance of the random.py IronPython library.
Console.WriteLine("Loading random.py");
ScriptRuntime py = Python.CreateRuntime();
dynamic random = py.UseFile("random.py");
Console.WriteLine("random.py loaded.");
// Initialize an enumerable set of integers
int[] items = Enumerable.Range(1, 7).ToArray();
// Randomly shuffle the array of integers by using IronPython.
for (int i = 0; i < 5; i++)
{
random.shuffle(items);
foreach (int item in items)
{
Console.WriteLine(item);
}
Console.WriteLine("-------------------");
}
}
}
}
IronPython 2.7.9 (2.7.9.0) on .NET 4.0.30319.42000 (64-bit) Type "help", "copyright", "credits" or "license" for more information.
.NET v4.0.30319
Path.Combine. You can also useDirectory.Existsto make sure your path is right. At a glance it looks like you're in the 32-bit program files and you have 64-bit installed. - Zer0string path1 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); string path2 = @"\IronPython 2.7.9 for .NET 4.0\Lib"; string path = Path.Combine(path1, path2); System.IO.Directory.SetCurrentDirectory(path);Like this? - Milliorn