File io error Python

Posted by serpiente on Stack Overflow See other posts from Stack Overflow or by serpiente
Published on 2010-04-06T03:51:19Z Indexed on 2010/04/06 3:53 UTC
Read the original article Hit count: 714

Filed under:
|
|

I have a program that monitors a folder with word documents for any modifications made on the files. The error -Windows Error[2] The system cannot find the file specified- comes when I run the program, open a .doc within the folder make some changes and save it. Any suggestions on how to fix this?

Here's the code:

    def archivar():
    txt = open('archivo.txt', 'r+' )
    for rootdir, dirs, files in os.walk(r"C:\Users\keinsfield\Desktop\colegio"):
        for file in files:
            time  = os.stat(os.path.join(rootdir, file)).st_ctime
            txt.write(file +','+str(time) + '\n')
def check():
    txt = [col.split(',') for col in (open('archivo.txt', 'r+').read().split('\n'))]
    files = os.listdir(r"C:\Users\keinsfield\Desktop\colegio")  
    for file in files:
        for info in txt:
                if info[0]==os.stat(os.path.join(r"C:\Users\keinsfield\Desktop\colegio",file)).st_ctime:
                print "modified"    

© Stack Overflow or respective owner

Related posts about file-io

Related posts about python