Solved

System.IO.IOException: The device is not ready

Posted on 2010-11-08
12
4,009 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
  • 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

786 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