Board index » delphi » I/O Error 123

I/O Error 123

I'm getting this error when I try to write to a file using writeln.  The
file is on a WinXP system and the filename may contain spaces.  I have
enclosed the full path and filename in "" to deal with the spaces.

Any ideas?

Thanks,

Jeff

 

Re:I/O Error 123


Quote
Jeff Patrick wrote:
> I'm getting this error when I try to write to a file using writeln.
> The file is on a WinXP system and the filename may contain spaces.  I
> have enclosed the full path and filename in "" to deal with the
> spaces.

kinda, this is not uncommon with long filenames, many routines dont
suppose the non 8.3 filenames, and treat it as different commands, eg

c:\program files\

turns into

c:\program
files\

Especially with parameters. I think if you're doing it internally, eg
you do

filename:='a long file.txt";

You can probably get away with it, its more of the

myapp a long file.txt

will see
param 1=a
param 2=long
param 3=file.txt

there isnt much you can do about that, thats very very normal.

For example

notepad c:\program files\borland\delphi5\readme.txt
edit c:\program files\borland\delphi5\readme.txt

notepad brings up the file, edit actually says "C:\documents and
settings\<username>\files\borland\delphi5\readme.txt doesnt exist"

Re:I/O Error 123


That is what I figure, but wouldn't enclosing the string in double quotes
take care of that? (i.e. strPath := '"c:\program files\test\"';)  If not is
there another way around it?  I'm trying to work with in a customer spec
that actually calls for directory and file names with spaces in them.

Thanks,

Jeff

Quote
"Liz" <liz_wants_no_s...@xcalibur.nospam.co.uk> wrote in message

news:xn0e30z3dh8jvgx000@newsgroups.borland.com...
Quote
> Jeff Patrick wrote:

>> I'm getting this error when I try to write to a file using writeln.
>> The file is on a WinXP system and the filename may contain spaces.  I
>> have enclosed the full path and filename in "" to deal with the
>> spaces.

> kinda, this is not uncommon with long filenames, many routines dont
> suppose the non 8.3 filenames, and treat it as different commands, eg

> c:\program files\

> turns into

> c:\program
> files\

> Especially with parameters. I think if you're doing it internally, eg
> you do

> filename:='a long file.txt";

> You can probably get away with it, its more of the

> myapp a long file.txt

> will see
> param 1=a
> param 2=long
> param 3=file.txt

> there isnt much you can do about that, thats very very normal.

> For example

> notepad c:\program files\borland\delphi5\readme.txt
> edit c:\program files\borland\delphi5\readme.txt

> notepad brings up the file, edit actually says "C:\documents and
> settings\<username>\files\borland\delphi5\readme.txt doesnt exist"

Re:I/O Error 123


In article <xn0e30z3dh8jvgx...@newsgroups.borland.com>, "Liz"

Quote
<liz_wants_no_s...@xcalibur.nospam.co.uk> wrote:
> For example

> notepad c:\program files\borland\delphi5\readme.txt
> edit c:\program files\borland\delphi5\readme.txt

> notepad brings up the file, edit actually says "C:\documents and
> settings\<username>\files\borland\delphi5\readme.txt doesnt exist"

no quotes!

 edit "c:\program files\borland\delphi5\readme.txt"
works fine for me.

----------
The original question is not sufficiently accurate.
How can writeln give an error about a filename, it doesn't *take* a
file*name*, just an (optional) file, which must be open for output.

Re:I/O Error 123


Quote
In article <429f2...@newsgroups.borland.com>, Jeff Patrick wrote:
> I'm getting this error when I try to write to a file using writeln.  The
> file is on a WinXP system and the filename may contain spaces.  I have
> enclosed the full path and filename in "" to deal with the spaces.

> Any ideas?

Without seeing the actual path/filename you are using it is hard to make a
diagnosis. There are characters that are illegal in a path or file, for
example (like a colon other than the one after the drive letter), and for
files on a net share you are best served to stay away from characters not
in the 7 bit ANSI characters...

--
Peter Below (TeamB)  
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be

Re:I/O Error 123


Quote
Iain Macmillan wrote:
> no quotes!

I know, I was demonstrating a windows app vs a non windows app
interpretation

Re:I/O Error 123


Quote
> That is what I figure, but wouldn't enclosing the string in double
quotes
> take care of that? (i.e. strPath := '"c:\program files\test\"';)  If
not is
> there another way around it?  I'm trying to work with in a customer
spec
> that actually calls for directory and file names with spaces in

them.

Hi,

You shouldn't need to include double-quotes in your code - the
quote marks are only required on the command line, and Windows will
remove
them before passing the command-line arguments to your program
(test it and see).

I/O Error 123 is an invalid name error. Delphi is trying to
access a file called "c:\program files\test\" (including the
double-quotes)
which is an illegal file name since it contains colons and backslashes
(I'm not sure if double-quotes are valid characters either).

Try removing the double-quotes you have added.

As far as I remember, there is nothing special you have to do
to handle long file names and file paths containing spaces, except
if you are launching other applications from within yours.

Cheers,

Chris

Other Threads