Solved

System.IO.IOException: The device is not ready

Posted on 2010-11-08
12
4,395 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

632 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