Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4776
  • Last Modified:

System.IO.IOException: The device is not ready

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
melinalt
Asked:
melinalt
  • 5
  • 5
1 Solution
 
puru1981Commented:
Check if the user has permission for write at the location.
0
 
melinaltAuthor Commented:
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
 
puru1981Commented:
One thing more are you closing the aPath and aWork files. this error occurs when the file is in use.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
melinaltAuthor Commented:
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
 
puru1981Commented:
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
 
melinaltAuthor Commented:
I am afraid I can't since these are all art files (jpg, ia, png, etc)  :(
0
 
puru1981Commented:
it is happening randomly or every time??
0
 
melinaltAuthor Commented:
For one user is randomly for the other one is all the time.
0
 
puru1981Commented:
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
 
melinaltAuthor Commented:
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
 
Kumaraswamy RCommented:
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

Independent Software Vendors: 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!

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now