Re: Serialization problem
- From: Nikola Novak <enlorkMAKNI@xxxxxxxxxxxx>
- Date: Thu, 5 Feb 2009 11:07:50 +0100
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
.
- Follow-Ups:
- Re: Serialization problem
- From: Peter Duniho
- Re: Serialization problem
- References:
- Serialization problem
- From: Nikola Novak
- Re: Serialization problem
- From: Ignacio Machin ( .NET/ C# MVP )
- Re: Serialization problem
- From: Nikola Novak
- Re: Serialization problem
- From: Nikola Novak
- Re: Serialization problem
- From: Nikola Novak
- Re: Serialization problem
- From: Jeff Johnson
- Re: Serialization problem
- From: Nikola Novak
- Re: Serialization problem
- From: Jeff Johnson
- Re: Serialization problem
- From: Nikola Novak
- Re: Serialization problem
- From: Peter Duniho
- Re: Serialization problem
- From: Nikola Novak
- Re: Serialization problem
- From: Peter Duniho
- Serialization problem
- Prev by Date: Setup project
- Next by Date: Re: Context Menue Strip Qyuestion
- Previous by thread: Re: Serialization problem
- Next by thread: Re: Serialization problem
- Index(es):
Relevant Pages
|