Here are the examples of the python api System.IO.File.Exists taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
3
Example 1
Project: ironpython3 Source File: assert_util.py
def load_iron_python_dll():
import clr
from System.IO import File
#When assemblies are installed into the GAC, we should not expect
#IronPython.dll to exist alongside IronPython.dll
if File.Exists(path_combine(sys.prefix, "IronPython.dll")):
clr.AddReferenceToFileAndPath(path_combine(sys.prefix, "IronPython.dll"))
else:
clr.AddReference("IronPython")
3
Example 2
Project: ironpython3 Source File: cominterop_util.py
def IsExcelInstalled():
from Microsoft.Win32 import Registry
from System.IO import File
excel = None
#Office 11 or 12 are both OK for this test. Office 12 is preferred.
excel = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\12.0\\Excel\\InstallRoot")
if excel==None:
excel = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\11.0\\Excel\\InstallRoot")
#sanity check
if excel==None:
return False
#make sure it's really installed on disk
excel_path = excel.GetValue("Path") + "excel.exe"
return File.Exists(excel_path)
3
Example 3
Project: ironpython3 Source File: cominterop_util.py
def IsWordInstalled():
from Microsoft.Win32 import Registry
from System.IO import File
word = None
#Office 11 or 12 are both OK for this test. Office 12 is preferred.
word = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\12.0\\Word\\InstallRoot")
if word==None:
word= Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\11.0\\Word\\InstallRoot")
#sanity check
if word==None:
return False
#make sure it's really installed on disk
word_path = word.GetValue("Path") + "winword.exe"
return File.Exists(word_path)
0
Example 4
def isfile(self, filename):
return File.Exists(filename)