2017-08-01 109 views
0

我的程序的這一部分打開一個文件,下載到掃描儀上進行刷新。如果我剛剛關閉了文件選擇窗口,我收到此錯誤消息 -如何檢查tk_getOpenfile是否實際打開文件?

wrong # args: should be cksum ?-format string? -channel chan | -filename file | string 
wrong # args: should be cksum ?-format string? -channel chan | -filename file | string 
    while executing 
"::crc::cksum -file $file2program" 


set file2program [tk_getOpenFile] 

## determine chsum 
set filechecksum1 [::crc::cksum -file $file2program] 
set filechecksum [format %X [scan $filechecksum1 %d]] 
.flashutility.messagearea insert end "Checksum for binary file = $filechecksum\n" 
.flashutility.messagearea see end 
set filesize [file size $file2program] 
.flashutility.messagearea insert end "Size of the file to transfer is $filesize bytes\n" 
.flashutility.messagearea see end 
update 

回答

0

tk_getOpenFile命令不會打開該文件。它返回要打開的文件的全限定名稱。如果用戶取消,則返回空字符串,這與任何平臺上的任何完全限定的文件名都不相同。