Re: Serialization problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Thu, 05 Feb 2009 00:57:07 -0800, Peter Duniho wrote:

On Thu, 05 Feb 2009 00:40:23 -0800, Nikola Novak
<enlorkMAKNI@xxxxxxxxxxxx> wrote:

It's a good thing I usually work in Linux.

Why? Is there something about Linux that allows a person to write code
without reading the documentation, or without understanding how the basic
OS API works?

In any case, the real lesson here is that you shouldn't be making
assumptions about the working directory when dealing with filenames. This
is true even in non-Windows operating systems, including Linux. File i/o
operations should specify a complete path, because there's no way for the
code trying the operation to guarantee that the default/working directory
is correct for that code (unless it sets it explicitly, but that's only
safe in a single-threaded environment anyway).

Pete

There is nothing about Linux that allows a person to write code without
reading the documentation, of course. However, there is one thing about
Linux that makes it much easier for a programmer to know what's going on in
a given scenario, and that's the fact that the documentation is complete
and unambiguous (or at least the part of it that I read was).

I've often found a solution to my problem on Linux on its 'man' pages.
Here, the particular property I should have been looking at for this to not
happen (RestoreDirectory) is explained ambiguously enough for me to think
it does something completely different -- something I don't want for it to
do, so I've had it deliberately set to false, which is its default value.

Never does MSDN say that OFD, or any other control/dialog will change my
working directory, so I was content with having the following line written
in my constructor:

Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath));

An equivalent code in C++ on Linux would've been enough to ensure that all
fopen's (or whatever other functions I use for opening files) in my code
open my files in the same directory as the executable that started it is
placed in -- unless I specify otherwise.

Nikola
.



Relevant Pages

  • Re: To the Brotherhood of the Consoles (Warning contains Wibble)
    ... >Linux challenges you. ... >documentation, waiting for compiles, sifting through newsgroups & ... Instead of reading documentation ...
    (comp.sys.sinclair)
  • Re: Programming PowerPC on Mac
    ... The documentation about how to program Windows with assembly language was, ... Linux and X and such with LuxAsm...because, over on Linux, it's the same ... There's nothing "official" only what ordinary developers (like ...
    (alt.lang.asm)
  • Linux Frequently Asked Questions with Answers (Part 6 of 6)
    ... stable kernel) you have discovered a bug in GCC. ... Refer to: ("The Machine Runs ... Linux is a very good memory tester--much better than MS-DOS based ... documentation that comes with util-linux to find out how to do this. ...
    (comp.os.linux.misc)
  • Linux Frequently Asked Questions with Answers (Part 6 of 6)
    ... stable kernel) you have discovered a bug in GCC. ... Refer to: ("The Machine Runs ... Linux is a very good memory tester--much better than MS-DOS based ... documentation that comes with util-linux to find out how to do this. ...
    (comp.os.linux.misc)
  • Linux Frequently Asked Questions with Answers (Part 6 of 6)
    ... stable kernel) you have discovered a bug in GCC. ... Refer to: ("The Machine Runs ... Linux is a very good memory tester--much better than MS-DOS based ... documentation that comes with util-linux to find out how to do this. ...
    (comp.os.linux.misc)