troubleshooting Question

Python - path

Avatar of craigdev
craigdev asked on
2 Comments1 Solution930 ViewsLast Modified:
Hi Im using Python from .NET and am getting a bit confused by the path variable.

Ideally I want to have my relevant .py files in a separate subfolder and be able to set that to wherever I like. So for instance I have a file called that sits in the same folder as my .NET executable, then the following .NET code allows me to run the test script .....


Imagine in this case that the path to the exe and .py folder is C:\app\app.exe and C:\app\

Now if I want to move the file to C:\app\pyfiles\ how would I change the path so Python can find it in the new folder?

PythonEngine.ImportModule("pyfiles\test") does not seem to work.

Furthermore, in the file I am writing a new text file with this code: f = file(' newfile.txt', 'w') so the newfile.txt appears in whichever folder the script sits in. Ideally I would like to be able to write to a folder such as C:\app\output instead of just whichever folder python is working from.

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros