EldoS | Feel safer!

Software components for data protection, secure storage and transfer

File.Copy want work..

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
#10436
Posted: 06/19/2009 06:19:13
by Bastian Moldenhauer (Standard support level)
Joined: 06/04/2009
Posts: 40

Hi,

i used the sample code provided to create a virtual filesystem. Then i modified the UI a bit and added code thats throws up an exception telling me that a device attached to the system is not working.

Here the code:
Code
            using (FileStream source = File.Create(edtMountinPoint + "\\small_file.txt"))
            {
                source.SetLength(1024 * 1024 * 2); //2mb
            }

            File.Copy(edtMountinPoint + "\\small_file.txt", edtMountinPoint + "\\small_file_copy.txt");


I debugged the virtual filesystem provided by eldos and found out that the exception throws bevor the destination file is created. it seems that the exception throws between opening the source and opening the destination file.

Somebody has the same problems? Or can someone explain me in more detail what File.Copy does internaly? Maybe that helps to figure what leads to this exception.

Thanks in advance.
Regards
#10438
Posted: 06/19/2009 06:43:05
by Volodymyr Zinin (EldoS Corp.)

Hi,

Please specify what the sample (there are three of them) are you using? And what the name does the modified function have?
Thanks.
#10439
Posted: 06/19/2009 07:51:53
by Bastian Moldenhauer (Standard support level)
Joined: 06/04/2009
Posts: 40

Hi,

we used the VDisk .Net example. We did not really modify an existing method. we added a new button + click event which executes the code above.

This example works:
Code
FileStream fs = File.Create(edtMountinPoint + "\\big_file.txt");

            fs.SetLength(1024 * 1024 * 200);//200mb file

            using (Stream stream = new DeflateStream(new FileStream(edtMountinPoint+"\\big_deflate.txt",FileMode.Create), CompressionMode.Compress)){
                fs.Seek(0, SeekOrigin.Begin);
                CopyStream(fs, stream);
            }

        private static void CopyStream(Stream source, Stream destination)
        {
            Byte[] buffer = new Byte[1024 * 1024];
            int c = source.Read(buffer, 0, buffer.Length);
            do
            {
                destination.Write(buffer, 0, buffer.Length);
                c = source.Read(buffer, 0, buffer.Length);
            }
            while (c > 0);
        }


Hope this information helps.

Regards
#10440
Posted: 06/19/2009 09:07:45
by Volodymyr Zinin (EldoS Corp.)

Thank you. We will check where the problem is and answer a little later.
#10441
Posted: 06/19/2009 12:52:37
by Volodymyr Zinin (EldoS Corp.)

Hi,

I've checked it and the code from the top message works if edtMountinPoint.Text is used instead of edtMountinPoint.
#10528
Posted: 07/06/2009 05:49:38
by Bastian Moldenhauer (Standard support level)
Joined: 06/04/2009
Posts: 40

Hi,

I found out that one of my colleague changed some code. In ReadFile which seemed to cause the problem.

It was not edtMountinPoint.Text..in our code edtMountinPoint was a string ;-)

So nevermind and thanks for your help.
Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages

Reply

Statistics

Topic viewed 2334 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!