Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > File IO error

Reply
Thread Tools

File IO error

 
 
John
Guest
Posts: n/a
 
      11-02-2006
Hi all:

I have a web application that plugs into to allow users to read local files
and then upload those files to Sharepoint, but for some reason when I try to
run the code from a client machine (it works fine on the server) I get the
following exception:

System.IO.IOException: The device is not ready.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess
access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize,
FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean
bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access)
at WebService1.WebForm1.uploadDocToSts() in
c:\Inetpub\Development\stsupload\upload.aspx.cs:li ne 141

Here is the code:

try
{
// Grab the local file and read it into the buffer
FileStream fStream = new FileStream(sFileName, FileMode.Open,
FileAccess.Read);
byte[] byteBuffer = new byte[fStream.Length];
fStream.Read(byteBuffer, 0, Convert.ToInt32(fStream.Length));
fStream.Close();

}
catch (Exception F)
{
txtDebug.Text += "File Error " + F.ToString();
}
Can anyone make a suggestion?

John.


 
Reply With Quote
 
 
 
 
Jeff Dillon
Guest
Posts: n/a
 
      11-02-2006
What do you mean "on the client". What you posted is server code. sFileName
better be a file on the server


"John" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi all:
>
> I have a web application that plugs into to allow users to read local
> files and then upload those files to Sharepoint, but for some reason when
> I try to run the code from a client machine (it works fine on the server)
> I get the following exception:
>
> System.IO.IOException: The device is not ready.
> at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
> at System.IO.FileStream.Init(String path, FileMode mode, FileAccess
> access, Int32 rights, Boolean useRights, FileShare share, Int32
> bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String
> msgPath, Boolean bFromProxy)
> at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
> access)
> at WebService1.WebForm1.uploadDocToSts() in
> c:\Inetpub\Development\stsupload\upload.aspx.cs:li ne 141
>
> Here is the code:
>
> try
> {
> // Grab the local file and read it into the buffer
> FileStream fStream = new FileStream(sFileName, FileMode.Open,
> FileAccess.Read);
> byte[] byteBuffer = new byte[fStream.Length];
> fStream.Read(byteBuffer, 0, Convert.ToInt32(fStream.Length));
> fStream.Close();
>
> }
> catch (Exception F)
> {
> txtDebug.Text += "File Error " + F.ToString();
> }
> Can anyone make a suggestion?
>
> John.
>
>



 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      11-03-2006
"John" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi all:
>
> I have a web application that plugs into to allow users to read local
> files and then upload those files to Sharepoint, but for some reason when
> I try to run the code from a client machine (it works fine on the server)
> I get the following exception:
>
> System.IO.IOException: The device is not ready.
> at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
> at System.IO.FileStream.Init(String path, FileMode mode, FileAccess
> access, Int32 rights, Boolean useRights, FileShare share, Int32
> bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String
> msgPath, Boolean bFromProxy)
> at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
> access)
> at WebService1.WebForm1.uploadDocToSts() in
> c:\Inetpub\Development\stsupload\upload.aspx.cs:li ne 141


Here's how to fix this. Assume that your computer isn't lying.

If that's true, then there's a real device that's really not ready.

Which device could it be?

try
{
FileStream s = new FileStream(sFileName, ...);
}
catch (Exception ex)
{
throw new Exception(string.Format("Can't deal with file {0}",
sFileName), ex);
}


John


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0xffc Thread 0x228 DBC 0x437b94 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr bazzer ASP .Net 0 03-30-2006 03:16 PM
Error connecting to SQLExpress 2005 locally (error: 26 - Error Locating Server/Instance Specified) hfk0 ASP .Net 2 03-27-2006 08:43 PM
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x8fc Thread 0x934 DBC 0x437b94 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr bazzer ASP .Net 1 03-24-2006 04:20 PM
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x8fc Thread 0x934 DBC 0x437b94 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr bazzer ASP .Net 0 03-24-2006 02:22 PM
Error 500: ERROR: Cannot forward. Writer or Stream already obtained. Error JavaQueries Java 1 03-01-2005 06:30 PM



Advertisments