Question IOException

kkprakashmsc

Member
Joined
Jan 2, 2009
Messages
8
Programming Experience
1-3
While using FileSystem.CopyDirectory to copy a directory to the destination path, it produces IOEXception was caught - "Couldnot complete operations on some files or directories". How to Solve this?
 
I've found reference on the web that the full error is actually:

"Could not complete operation on some files and directories. See the data property of the exception for more details"

That would be the first thing I would do -> see the Data property
 
Data property of that Exception:

System.Collections.ListDictionaryInternal
That's what type it is. Now, what does it contain? The documentation for the IOException.Data property says that it's type IDictionary. The IDictionary interface defines a Keys property that contains all the keys and you can use each key to get the corresponding value:
VB.NET:
Catch ex As IO.IOException
    MessageBox.Show(ex.ToString())

    For Each key As Object In ex.Data.Keys
        MessageBox.Show(ex.Data(key).ToString(), key.ToString())
    Next
End Try
 
Yeah i tried ,the exception's Data property is "Access to the path is denied"
The file attribute of that file is :ReadOnly.
I tried by changing its attribute to Not Readonly. But still i am facing the same error.

for ex, i have a file named one.jpg which is readonly in a directory
i need to copy this directory to another path which already contains the file one.jpg which is also readonly and i have used CopyDirectory method of FileSystem with the OverWrite value as True
 
You cannot copy a file over another file that is read-only, because overwriting obviously requires writing, which you cannot do to a read-only file. It doesn't matter whether the source file is read-only or not because you're not writing to that file. It's the target file that matters.
 
Back
Top