Solved

System.IO.IOException: The device is not ready

Posted on 2010-11-08
12
4,229 Views
Last Modified: 2012-05-10
I have an ASP .NET application that is copying two files to a new location.
All users work perfect except for only two that are getting the following error:

Exception of type 'System.Web.HttpUnhandledException' was thrown.: System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.IO.IOException: The device is not ready. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite) at System.IO.FileInfo.CopyTo(String destFileName, Boolean overwrite)

See code below.

Thanks,
Dim aPath As New IO.FileInfo(strArtPath)
        Dim aWork As New IO.FileInfo(strArtWork)
        aPath.CopyTo("\\prodart\markport\" & newarchiveID & aPath.Extension, True)
        aWork.CopyTo("\\prodart\markport\" & newarchiveID & aWork.Extension, True)

Open in new window

0
Comment
Question by:melinalt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
12 Comments
 
LVL 9

Expert Comment

by:puru1981
ID: 34086269
Check if the user has permission for write at the location.
0
 
LVL 1

Author Comment

by:melinalt
ID: 34086308
Thanks puru1981:
All my users have full access/rights to the server.
I am also using identity impersonate in my webconfig (using the administrator credentials)
<identity impersonate="true" userName="server\administrator" password="administratorpassword"/>
0
 
LVL 9

Expert Comment

by:puru1981
ID: 34086441
One thing more are you closing the aPath and aWork files. this error occurs when the file is in use.
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 1

Author Comment

by:melinalt
ID: 34086485
ok.. so that is probably what's happening but I can't find an atribute/member to close the file.

These don't work with IO.Systemfile

aWork.close()
aWork.dispose()

Or should I do something like this?

 Using workfs As IO.FileStream = aWork.Open(IO.FileMode.Open, IO.FileAccess.Write, IO.FileShare.ReadWrite)
            aWork.CopyTo("\\prodart\markport\" & newarchiveID & aWorkExtension, True)
 End Using

But not sure if it will work...

Thanks a lot for helping me out.

0
 
LVL 9

Expert Comment

by:puru1981
ID: 34086623
using is used only with classes which use IDisposable interface.

i think there is some other issue is preventing to copy the file. can you do one thing add same random string at the end of the file and then check if it still happens.
0
 
LVL 1

Author Comment

by:melinalt
ID: 34086927
I am afraid I can't since these are all art files (jpg, ia, png, etc)  :(
0
 
LVL 9

Expert Comment

by:puru1981
ID: 34087024
it is happening randomly or every time??
0
 
LVL 1

Author Comment

by:melinalt
ID: 34087264
For one user is randomly for the other one is all the time.
0
 
LVL 9

Accepted Solution

by:
puru1981 earned 500 total points
ID: 34087405
I think this is due to this

newarchiveID

once this is generated it is not allowing other threads to create the same.

so you need to be aware if the same archive id is used by all the users if first user is writing the file no other user can access it so you are getting the error.
0
 
LVL 1

Author Comment

by:melinalt
ID: 34087760
Good thinking but I don't think that is the problem. Let me explain the newarchiveID  a little bit more.

An user works in two versions of the same file
aPath is the path to the art file which is always a JPG
aWork is the path to the work file wich is an editable version of the JPG (illustrator, photoshop, etc).

When they finish working on the files they are requiered to copy both files to our art server.

When they do this, the system creates a unique id for each file  (newarchiveID) and copies both files to the art server, both with the same name (newarchiveID ) but they keep their extensions so we know what type of files are they.

So, the newarchiveID  is a unique consecutive number generated by the system to idenfity the set of files but it is totally different between users, so, there are not going to be two users using the same newarchiveID .

I do think that you are correct and the issue has to do with the fact that the file is not being closed, after copied.


0
 
LVL 29

Expert Comment

by:Kumaraswamy R
ID: 34276665
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
asp.net open new page without popup blocker 8 57
asp.net figure out error 3 47
Securing WEBAPI on Azure 2 57
ASP.net Moving Visual Studio 2015 project to 2017 2 71
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question