Hello Pyrevit Friends
I would like to open files with pyRevit. Text, Excel, PDF, etc. Also i would like to open folders in the explorer.
I started testing with a .txt file but I´m getting errors with every method i try.
Would appreciate any help
Kind regards!
import os
import sys
open("C:\\test.txt",'r')
os.startfile("C:\\test.txt")
os.system(r"C:\\test.txt")
IOError: [Errno 2] Die Datei "C:\test.txt" konnte nicht gefunden werden.: C:\test.txt
Script Executor Traceback:
System.IO.FileNotFoundException: Die Datei "C:\test.txt" konnte nicht gefunden werden.
Dateiname: "C:\test.txt"
bei System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
bei System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
bei System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
bei Microsoft.Scripting.PlatformAdaptationLayer.OpenInputFileStream(String path, FileMode mode, FileAccess access, FileShare share)
bei IronPython.Runtime.PythonFile.__init__(CodeContext context, String name, String mode, Int32 buffering)
bei IronPython.Modules.Builtin.open(CodeContext context, String name, String mode, Int32 buffering)
bei Microsoft.Scripting.Interpreter.FuncCallInstruction`5.Run(InterpretedFrame frame)
bei Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
bei Microsoft.Scripting.Interpreter.LightLambda.Run5[T0,T1,T2,T3,T4,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
bei System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
bei Microsoft.Scripting.Interpreter.DynamicInstruction`5.Run(InterpretedFrame frame)
bei Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
bei Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
bei IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
bei PyRevitLabs.PyRevit.Runtime.IronPythonEngine.Execute(ScriptRuntime& runtime)