Preventing "Can't write" error - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Preventing "Can't write" error

LordBugLordBug Posts: 12Member
In a little program I knocked up, I'm using ini files. When the program closes, it saves some things to the ini file.

By accident, I found that when the program is on an unwritable medium (eg CD), it comes back with an error message along the lines of "Cannot write to INI file", which keeps on coming back, no matter how many times you press OK. The only way I could kill it in the end was to use ProcessExplorer (Not even TaskManager worked).

Can someone suggest to me how I'd get around this error, and replace it with my own (Which would be a single message of "Unable to save settings" and then the program finishes closing)

Cheers

Comments

  • softmansoftman Posts: 157Member
    : In a little program I knocked up, I'm using ini files. When the program closes, it saves some things to the ini file.
    :
    : By accident, I found that when the program is on an unwritable medium (eg CD), it comes back with an error message along the lines of "Cannot write to INI file", which keeps on coming back, no matter how many times you press OK. The only way I could kill it in the end was to use ProcessExplorer (Not even TaskManager worked).
    :
    : Can someone suggest to me how I'd get around this error, and replace it with my own (Which would be a single message of "Unable to save settings" and then the program finishes closing)
    :
    : Cheers
    :
    Hi!

    The file writing part is in try /except block? If it is not, try using it for handling the above exception by yourself.

    Bye
    \///
    /O O
    | | |
    | _ |
    ___/
    SoftMan

  • porodoroporodoro Posts: 230Member
    : : In a little program I knocked up, I'm using ini files. When the program closes, it saves some things to the ini file.
    : :
    : : By accident, I found that when the program is on an unwritable medium (eg CD), it comes back with an error message along the lines of "Cannot write to INI file", which keeps on coming back, no matter how many times you press OK. The only way I could kill it in the end was to use ProcessExplorer (Not even TaskManager worked).
    : :
    : : Can someone suggest to me how I'd get around this error, and replace it with my own (Which would be a single message of "Unable to save settings" and then the program finishes closing)
    : :
    : : Cheers
    : :
    : Hi!
    :
    : The file writing part is in try /except block? If it is not, try using it for handling the above exception by yourself.
    :
    : Bye
    : \///
    : /O O
    : | | |
    : | _ |
    : ___/
    : SoftMan
    :
    :
    Yes i think it is. I've used it many times.

    [code]
    try
    your code..

    except
    application.terminate or leave it empty
    end;

Sign In or Register to comment.