Alphaleonis.Win32.Filesystem.File.Copy

Jul 28, 2014 at 9:15 PM
Hi,

First off.. AMAZING project. you are helping developers around the world reclaim HOURS of their lives, myself included! Thank you :-)

Now.. an interesting one for you. I'm running into a glitch with the
Alphaleonis.Win32.Filesystem.File.Copy method. I'm have a project which scans and processes millions upon millions of files and I'm looking at this assembly to help add long path support to it. I've been getting some odd behaviour which I have tracked down to this method.

I can best highlight it with an example..

Create a simple win forms project and add two text box's and a button, then pop this in the button click event....

Alphaleonis.Win32.Filesystem.File.Copy(Me.TextBox1.Text, Me.TextBox2.Text, True)

Add a reference to the AlphaFS assembly.

On my system I enter \mark-pc\data1\1\Accounts 2009-2010.xlsx into text box1 and \mark-pc\archive1\mark-pc-data1-1\Accounts 2009-2010.xlsx into text box 2. I click the button and an exception gets thrown.

The paths are definitely valid and I can access them via explorer. I have checked and its definitely not a permissions issue.

The error is a 'DirectoryNotFoundException" and the message text is "Directory not found:\mark-pc\data1\1\Accounts 2009-2010.xlsx".

What am I doing wrong?

If I replace the line with "my.computer.filesystem.copyfile(Me.TextBox1.Text, Me.TextBox2.Text, True) then it works fine.
Developer
Jul 29, 2014 at 6:12 AM
Mark,

"\mark-pc\data1\1\Accounts 2009-2010.xlsx" and "\mark-pc\archive1\mark-pc-data1-1\Accounts 2009-2010.xlsx"

As far as I can tell, both paths are missing an extra backslash (?) to form a valid UNC path,
or is it just a typo here?

Also, is this happening with the latest dev build?
Jul 29, 2014 at 10:07 PM
Ok, figured it out :-)

It wasn't a typo. In the code there was a line to create the destination folder before Alphaleonis.Win32.Filesystem.File.move was called.

But in the block that called Alphaleonis.Win32.Filesystem.File.Copy there was no line to create the destination folder, therefore in some instances the destination folder didn't already exist and the call failed.

Mystery solved!

Thank you!

Mark
Marked as answer by Yomodo on 7/29/2014 at 11:18 PM