WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-27-2011, 10:55 AM
jassel41 jassel41 is offline
Member
 
Join Date: Nov 2009
Posts: 24
Check if file exists

Is there a way to check if a file exists in the current directory through code?

I don't want to access this file per say, I just want to verify that it already exists in the directory.

Thanks,
Jassel41
Reply With Quote
  #2  
Old 09-27-2011, 10:58 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You can use the os.path.isfile command to check for file existence.
Code:
import os
if os.path.isfile('foo.txt'):
    print 'File exists'
Reply With Quote
  #3  
Old 09-27-2011, 11:22 AM
jassel41 jassel41 is offline
Member
 
Join Date: Nov 2009
Posts: 24
That's perfect, thank you so much.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing of an imported .py file Uttama_vizard Vizard 2 05-04-2010 06:18 AM
IVEx file extenstion unrecognised. sindi Vizard 2 12-10-2009 01:20 AM
writing joystick position to a data file Saz Vizard 3 12-17-2008 05:18 AM
Read file....many issues Uttama_vizard Vizard 9 07-08-2008 02:16 PM
File Management Uttama_vizard Vizard 2 07-01-2008 09:44 AM


All times are GMT -7. The time now is 11:25 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC