我已經比較了兩個文件,並在臨時文件中存儲了不匹配的值。我已經提到這個link。之後,從臨時文件中讀取值並替換爲原始文件。最後我試圖刪除臨時文件。除臨時文件刪除外,所有進程都能正常工作。爲什麼臨時文件在NSIS中不被刪除?
我用下面的代碼:
page custom twofilecompare
page custom originalwrite
Function twofilecompare
FileOpen $0 "$INSTDIR\backup.properties" "r"
FileOpen $1 "$INSTDIR\orginal.properties" "r"
#IfFileExists "$INSTDIR\temp.properties" 0 +1
#Delete /REBOOTOK "$INSTDIR\temp.properties"
FileOpen $R0 "$INSTDIR\temp.properties" "w"
ClearErrors
loop:
FileRead $0 $2
${If} $2 == "$\r$\n"
Goto loop
${EndIf}
FindClose $0
FileRead $1 $3
IfErrors done
strcmp $2 $3 loop here
here:
FileWrite $R0 $2
Goto loop
done:
FileClose $0
FileClose $1
FileClose $R0
FunctionEnd
Function originalwrite
IfFileExists "$INSTDIR\temp.properties" 0 filenotfound
FileOpen $0 "$INSTDIR\temp.properties" "r"
loop:
FileRead $0 $1
IfErrors done
//do some stuff
done:
**IfFileExists "$INSTDIR\resource\temp.properties" 0 filenotfound
Delete /REBOOTOK "$INSTDIR\temp.properties"**
filenotfound:
MessageBox MB_OK "file not found"
FunctionEnd
即使我不能修改能力這三個文件[臨時,備份,原創]手動also.If我修改並點擊保存顯示爲提示「請檢查這個文件打開另一個程序「 我也使用完成後文件使用關閉文件。 連我都試過這種代碼也
Function .onInstSuccess
IfFileExists "$INSTDIR\temp.properties" notfound
MessageBox MB_OK "file exists"
Delete /REBOOTOK $INSTDIR\temp.properties
Goto done
notfound:
MessageBox MB_OK "file not found"
Done:
MessageBox MB_OK "file deleted"
FunctionEnd
但臨時文件不會被刪除。如何刪除臨時文件?
有人可以幫助我嗎?
在此先感謝
Thanks.Its工作。安裝後,我不能編輯bakcup和原屬性文件。提示框打開並顯示「請檢查此文件是否打開另一個程序」。但我已經關閉了三個文件。如何解決這個問題? – Ami