File.OpenWrite(...) file not found

G

Guest

I am writing out some files, using this syntax:

FileStream fw = File.OpenWrite(Filename);
fw.Write(bytearray,0,amount);
fw.Close();

The files appear in Windows Explorer, they show up from the DOS Cmd when I
do a wild card dir, but they cannot be copied in the DOS Cmd box. I get "file
not found". Am I missing a step; not doing something? This is .NET 1.1.
 
J

Jon Skeet [C# MVP]

Ron said:
I am writing out some files, using this syntax:

FileStream fw = File.OpenWrite(Filename);
fw.Write(bytearray,0,amount);
fw.Close();

The files appear in Windows Explorer, they show up from the DOS Cmd when I
do a wild card dir, but they cannot be copied in the DOS Cmd box. I get "file
not found". Am I missing a step; not doing something? This is .NET 1.1.

It would help if you gave us a step-by-step example of what's going
wrong, including what operating system you're using and what the
filename is.
 
G

Guest

Sure. The OS is XP Pro SP2. I did some experimentation and found that if the
filename has an extension, there is no problem. If the file name has no
extesion, this problem occurs. It doesn't matter what the file name is
otherwise.
 
J

Jon Skeet [C# MVP]

Ron said:
Sure. The OS is XP Pro SP2. I did some experimentation and found that if the
filename has an extension, there is no problem. If the file name has no
extesion, this problem occurs. It doesn't matter what the file name is
otherwise.

And how were you trying to copy the file? It should be fine either way.
 
G

Guest

Put double quotes arround the filename at the dos copy command. If there is
a space in the file name, the command would give an error as follows:

c:\> copy pod values.xls c:\public
The system cannot find the file specified

c:\> copy "pod values.xls" c:\public
1 file(s) copied.
 
G

Guest

I've tried double quotes. No go. The files are all legal ascii chars. I've
even tried assuming that there was an invisible trailing space, again, no go.

BUT NOW, I just tried it again and no problem!!! I'm sure it is due to me;
can't figure out how or why.

Thanks anyway to all for trying to help.

RON
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top