ded.diman
September 17th, 2008, 07:06 AM
Hi all.
I have a problem while trying to copy a file to the drive. For copying I use FileStream next way:
FileStream dstStream = new FileStream(dstFileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None);
int bytesToCopy = ...; //something appropriate
byte[] buffer = ...; //something appropriate
dstStream.Write(buffer, 0, bytesToCopy);
And it works fine on the whole. But only while the size of the file is greatly less than drive free space size (for proper work it should be less on 100-200 Kb at least). But if the size of the file is less than free space size only on 10-40 Kb than at FileStream.Write() call I have a System.IO.IOException. It is strange because file size is less than available free space. And copying of this file by Windows Explorer or different file managers causes no problem.
I tried to create FileStream instance by constructors where buffer size and option FileOptions.WriteThrough are specified. But it didn't help. :(
Maybe someone knows the reason of such behaviour and/or how it could be fixed?
Thanks.
I have a problem while trying to copy a file to the drive. For copying I use FileStream next way:
FileStream dstStream = new FileStream(dstFileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None);
int bytesToCopy = ...; //something appropriate
byte[] buffer = ...; //something appropriate
dstStream.Write(buffer, 0, bytesToCopy);
And it works fine on the whole. But only while the size of the file is greatly less than drive free space size (for proper work it should be less on 100-200 Kb at least). But if the size of the file is less than free space size only on 10-40 Kb than at FileStream.Write() call I have a System.IO.IOException. It is strange because file size is less than available free space. And copying of this file by Windows Explorer or different file managers causes no problem.
I tried to create FileStream instance by constructors where buffer size and option FileOptions.WriteThrough are specified. But it didn't help. :(
Maybe someone knows the reason of such behaviour and/or how it could be fixed?
Thanks.