problems writing to binary files 
Author Message
 problems writing to binary files

I'm using the following code to dump a byte array into a new file

FileStream fsWrite = new FileStream(DUMP_DIRECTORY +
_file,FileMode.Create,FileAccess.Write);
if (fsWrite.CanWrite) fsWrite.Write(_data,0,_data.Length);
fsWrite.Close();

However, it always return an error stating that it cannot find part of the
path

System.Web.Services.Protocols.SoapException: Server was unable to process
request. ---> System.IO.DirectoryNotFoundException: Could not find a part of
the path "C:\filedump\".
   at System.IO.__Error.WinIOError(Int32 errorCode, String str)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath,
Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access)
   at FileTransfer.TransferService.Transfer(String _file, Byte[] _data) in
c:\inetpub\wwwroot\filetransfer\transferservice.asmx.cs:line 71

I know that the directory exists, so I must be doing something wrond to be
getting this error. I set the directory security so that Everyone had write
access, so I don't think it's a problem with permissions. Any help would be
greatly appreciated. Thanks in advance.

- Devon Knowles



Tue, 07 Dec 2004 23:12:13 GMT  
 problems writing to binary files
What is DUMP_DIRECTORY and what is _file and do those
two concatenated end up being a full path?

It looks like _file might == "" in which case the file
name would be c:\filedump\ which is an invalid file name.

-c


Quote:
> I'm using the following code to dump a byte array into a new file

> FileStream fsWrite = new FileStream(DUMP_DIRECTORY +
> _file,FileMode.Create,FileAccess.Write);
> if (fsWrite.CanWrite) fsWrite.Write(_data,0,_data.Length);
> fsWrite.Close();

> However, it always return an error stating that it cannot find part of the
> path

> System.Web.Services.Protocols.SoapException: Server was unable to process
> request. ---> System.IO.DirectoryNotFoundException: Could not find a part
of
> the path "C:\filedump\".
>    at System.IO.__Error.WinIOError(Int32 errorCode, String str)
>    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
> access, FileShare share, Int32 bufferSize, Boolean useAsync, String
msgPath,
> Boolean bFromProxy)
>    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
> access)
>    at FileTransfer.TransferService.Transfer(String _file, Byte[] _data) in
> c:\inetpub\wwwroot\filetransfer\transferservice.asmx.cs:line 71

> I know that the directory exists, so I must be doing something wrond to be
> getting this error. I set the directory security so that Everyone had
write
> access, so I don't think it's a problem with permissions. Any help would
be
> greatly appreciated. Thanks in advance.

> - Devon Knowles




Tue, 07 Dec 2004 23:21:20 GMT  
 problems writing to binary files
You hypothesis was somewhat correct. Turns out that I forgot to update the
Web Reference so it wasn't passing the string at all, even though I set it
as a parameter. Thanks again for the help.

- Devon Knowles



Tue, 07 Dec 2004 23:54:35 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Binary file I/O using ofstream::write() blows away remaining data to end of file

2. reading and writing to binary files

3. Reading and Writing Ascii and Binary Files

4. write at a certain position in a binary file

5. Copying Over Elements Already Written to a binary File - mytest.cpp (0/1)

6. Help with writing to binary file through functions

7. Writing integers to binary file

8. read binary files written by VB with C

9. fast binary files writes

10. Portably writing double to binary file

11. Writing binary files in C to be read in MS FORTRAN 4.0

12. Write Binary File - Please Help !!

 

 
Powered by phpBB® Forum Software