SetAttributes throwing a nativeexception

Jun 9, 2010 at 1:36 PM
Hi. I'm trying to use AlphaFS to access long file paths, namely to access paths of source code that has been downloaded to my local system from subversion. I'm having an issue when trying to delete items in long paths. Before the actual delete is called a SetAttributes call is made to remove any read-only flags on the files. When that call is made, I get the following stack trace: 2010-06-07 08:03:04,547 [634114945795403267] ERROR ProjectIndexManager (DeleteCaches:77) (null) - Unable to delete project caches for [trunk_7] System.IO.DirectoryNotFoundException: Directory not found:C:\ProgramData\Software Company Name\Product Name\FileStore\SourceFileCache\long_path\t\trunk_7\maven-core\src\test\projects\lifecycle-executor\project-with-additional-lifecycle-elements\src\main\java\org\apache\maven\lifecycle\test\.svn\prop-base\App.java.svn-base ---> System.IO.DirectoryNotFoundException: The system cannot find the path specified. (Exception from HRESULT: 0x80070003) --- End of inner exception stack trace --- at Alphaleonis.Win32.NativeError.ThrowException(UInt32 errorCode, String readPath, String writePath) in G:\Server\AlphaFS-1.0Beta-Src\AlphaFS\NativeError.cs:line 83 at Alphaleonis.Win32.NativeError.ThrowException(String readPath, String writePath) in G:\Server\AlphaFS-1.0Beta-Src\AlphaFS\NativeError.cs:line 57 at Alphaleonis.Win32.Filesystem.File.SetAttributes(String path, FileAttributes fileAttributes) in G:\Server\AlphaFS-1.0Beta-Src\AlphaFS\Filesystem\File.cs:line 1025 at IOUtil.SetAttributes(String dir, FileAttributes attr)... Do SetAttributes simply not work on long paths, or is there some workaround you might suggest? Some way maybe to recursively remove the read-only flag on the whole directory tree? Also, does .NET 4.0 address the max path issues, or is it still a problem? Thanks, Chris
Jun 9, 2010 at 1:55 PM
To work with long paths you should use long path syntax.

Path.GetLongPath() and then use it in all other methods. otherwise it
is still bound by 255.

On 9 June 2010 06:36, ChrisMachemer <notifications@codeplex.com> wrote:
> From: ChrisMachemer
>
> Hi. I'm trying to use AlphaFS to access long file paths, namely to access
> paths of source code that has been downloaded to my local system from
> subversion. I'm having an issue when trying to delete items in long paths.
> Before the actual delete is called a SetAttributes call is made to remove
> any read-only flags on the files. When that call is made, I get the
> following stack trace: 2010-06-07 08:03:04,547 [634114945795403267] ERROR
> ProjectIndexManager (DeleteCaches:77) (null) - Unable to delete project
> caches for [trunk_7] System.IO.DirectoryNotFoundException: Directory not
> found:C:\ProgramData\Software Company Name\Product
> Name\FileStore\SourceFileCache\long_path\t\trunk_7\maven-core\src\test\projects\lifecycle-executor\project-with-additional-lifecycle-elements\src\main\java\org\apache\maven\lifecycle\test\.svn\prop-base\App.java.svn-base
> ---> System.IO.DirectoryNotFoundException: The system cannot find the path
> specified. (Exception from HRESULT: 0x80070003) --- End of inner exception
> stack trace --- at Alphaleonis.Win32.NativeError.ThrowException(UInt32
> errorCode, String readPath, String writePath) in
> G:\Server\AlphaFS-1.0Beta-Src\AlphaFS\NativeError.cs:line 83 at
> Alphaleonis.Win32.NativeError.ThrowException(String readPath, String
> writePath) in G:\Server\AlphaFS-1.0Beta-Src\AlphaFS\NativeError.cs:line 57
> at Alphaleonis.Win32.Filesystem.File.SetAttributes(String path,
> FileAttributes fileAttributes) in
> G:\Server\AlphaFS-1.0Beta-Src\AlphaFS\Filesystem\File.cs:line 1025 at
> IOUtil.SetAttributes(String dir, FileAttributes attr)... Do SetAttributes
> simply not work on long paths, or is there some workaround you might
> suggest? Some way maybe to recursively remove the read-only flag on the
> whole directory tree? Also, does .NET 4.0 address the max path issues, or is
> it still a problem? Thanks, Chris
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> ([email removed])
>
> To start a new discussion for this project, email
> [email removed]
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe or change your settings on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at codeplex.com



--
Sincerely,
Alexander N.
Jun 10, 2010 at 1:43 AM
Edited Jun 10, 2010 at 1:47 AM

Here's what I've got.  how does it need to change?

foreach(FileInfo f in directoryInfo.GetFiles())

   string fullName = f.fullName;

   File.SetAttributes(fullName, attr);

}

Jun 10, 2010 at 3:33 AM
Chris,
update to latest development branch. Disable signing in the AlphaFS
project properties, otherwise it wont' be usable.

And simply use following lines:

Alphaleonis.Win32.Filesystem.Directory.Delete(Path.GetLongPath(<your
regular directory name>), true, true);

it will take care of everything, like recursion and removing ReadOnly flags.

Cheers.

On 9 June 2010 18:43, ChrisMachemer <notifications@codeplex.com> wrote:
> From: ChrisMachemer
>
> Here's what I've got.  how does it need to change?  File is an AlphaLeonis
> class.
>
>
>
>
>
> <font size="2">
>
>
>
> </font>foreach(FileInfo f in directoryInfo.GetFiles())
>
>  File.SetAttributes(fullName, attr);
>
> }
>
> {
>
> <font size="2">
>
>
>
> </font>string fullName = f.FullName;
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> ([email removed])
>
> To start a new discussion for this project, email
> [email removed]
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe or change your settings on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at codeplex.com



--
Sincerely,
Alexander N.
Jun 11, 2010 at 1:08 AM

How do I get my machine to trust the assembly?  And if it's ever to be rolled out in a product, how would I make it so it goes out trusted, so people don't ned to worry about setting it as trusted?

Jun 11, 2010 at 1:28 AM
When it's ready to go to production "decaf" - the main developer, with
sign it with his private key and everybody will use it without
problems.
The delay signing is done to prevent security problems, possible
mixture of released library with developed one and etc.
use this command to skip verification:

sn -Vr <assembly>
http://blogs.msdn.com/b/shawnfa/archive/2004/03/17/91575.aspx

Or just simply compile it without signing at all, and use it before
actual release comes out.

Could you delete an SVN folder you had problems with?


On 10 June 2010 18:08, ChrisMachemer <notifications@codeplex.com> wrote:
> From: ChrisMachemer
>
> How do I get my machine to trust the assembly?  And if it's ever to be
> rolled out in a product, how would I make it so it goes out trusted, so
> people don't ned to worry about setting it as trusted?
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> ([email removed])
>
> To start a new discussion for this project, email
> [email removed]
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe or change your settings on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at codeplex.com



--
Sincerely,
Alexander N.
Jun 15, 2010 at 10:43 AM

Greetings.

I'm happy to report that I'm now able to delete the long-path items from my program, using this snapshot of AlphaFS.

Now the question becomes, how do I properly sign it, so that it can be installed on someone else's machine?  I tried compiling it unsigned, but then my application won't even compile, saying 'referenced assemby "AlphaFS" does not have a strong name'.  I can use the sn -Vr command to make an exception on my dev and buildmachines, but I don't want to do that on every user's machine that would use that application.

Thanks,

Chris

Jun 15, 2010 at 2:49 PM
Chris,
if you unchecked the whole signing tab in AlphaFS but still have it in
your main project (from which you inlude AlphaFS) then it will fail
with the mentioned error.

In this case you need to uncheck signing of projects that utilize
AlphaFS as well.

Cheers.

On 15 June 2010 03:43, ChrisMachemer <notifications@codeplex.com> wrote:
> From: ChrisMachemer
>
> Greetings.
>
> I'm happy to report that I'm now able to delete the long-path items from my
> program, using this snapshot of AlphaFS.
>
> Now the question becomes, how do I properly sign it, so that it can be
> installed on someone else's machine?  I tried compiling it unsigned, but
> then my application won't even compile, saying 'referenced assemby "AlphaFS"
> does not have a strong name'.  I can use the sn -Vr command to make an
> exception on my dev and buildmachines, but I don't want to do that on every
> user's machine that would use that application.
>
> Thanks,
>
> Chris
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> ([email removed])
>
> To start a new discussion for this project, email
> [email removed]
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe or change your settings on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at codeplex.com



--
Sincerely,
Alexander N.
Jun 15, 2010 at 6:34 PM

It would appear its not that easy.  I've unchecked signing for my entire solution (27 projects) and it still wont work.  When might a new signed, released version come from AlphaFS?

 

-Chris

Jun 24, 2010 at 2:05 PM

Is the snapshot build supposed to work on Windows XP?  It's throwing an error:

System.TypeInitializationException: The type initializer for 'Koders.KodeShare.Plugins.ConcretePluginManager' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'KtmW32': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

   at Alphaleonis.Win32.Filesystem.NativeMethods.CreateTransaction(SecurityAttributes lpTransactionAttributes, IntPtr UOW, UInt32 CreateOptions, UInt32 IsolationLevel, UInt32 IsolationFlags, UInt32 Timeout, String Description)

   at Alphaleonis.Win32.Filesystem.KernelTransaction..ctor(ObjectSecurity securityDescriptor, UInt32 timeout, String description)

Jun 24, 2010 at 4:21 PM
Hi Chris,

Microsoft's Transacted NTFS is not supported on Windows prior to Vista.
What method did you want to use?


On 24 June 2010 07:06, ChrisMachemer <notifications@codeplex.com> wrote:
> From: ChrisMachemer
>
> Is the snapshot build supposed to work on Windows XP?  It's throwing an
> error:
>
> System.TypeInitializationException: The type initializer for
> 'Koders.KodeShare.Plugins.ConcretePluginManager' threw an exception. --->
> System.DllNotFoundException: Unable to load DLL 'KtmW32': The specified
> module could not be found. (Exception from HRESULT: 0x8007007E)
>
>    at
> Alphaleonis.Win32.Filesystem.NativeMethods.CreateTransaction(SecurityAttributes
> lpTransactionAttributes, IntPtr UOW, UInt32 CreateOptions, UInt32
> IsolationLevel, UInt32 IsolationFlags, UInt32 Timeout, String Description)
>
>    at Alphaleonis.Win32.Filesystem.KernelTransaction..ctor(ObjectSecurity
> securityDescriptor, UInt32 timeout, String description)
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> ([email removed])
>
> To start a new discussion for this project, email
> [email removed]
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe or change your settings on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at codeplex.com



--
Sincerely,
Alexandr Normuradov
Jun 28, 2010 at 4:35 PM
This particular error is being thrown on Directory.getFiles, but I'm sure there are numerous others. Is AlphaFS abandoning support of XP, or could you include XP-friendly versions of various methods? Also, fyi: the .Exists calls on both FileInfo and DirectoryInfo were giving me trouble. It seems if the path includes a trailing space, exists is set to false. I've put in a check for trailing spaces, and remove them if they're present in the Refresh methods, that seems to do the trick. public override void Refresh() { String tempPath = null; if (FullPath != null) tempPath = FullPath + ""; if (tempPath.EndsWith("\\")) tempPath = tempPath.Substring(0,tempPath.Length-1); mFileSystemEntryInfo = File.GetFileSystemEntryInfo(tempPath); if (mFileSystemEntryInfo != null && mFileSystemEntryInfo.IsDirectory) { mExists = true; } else { mExists = false; mFileSystemEntryInfo = null; } } Thanks, Chris
Jun 28, 2010 at 10:19 PM

Chris,

the latest development commit has a bug fix for Directory class. Forgot to update old references :(

About the trailing slash. Try not to pass any entries with trailing slash because it doesn't have a meeting in Windows like in *nix, except when used to specify a root directory, i.e C:\ where C: is the device and \ is the root directory. All the other directories shouldn't have it, because then it is being used as part of a search string ilke C:\blah\*.txt

Directory class has many advanced methods like GetFullFileSystemEntries which is enumerable and doesn't require arrays, and also returns a complete info about a file system object. It's way faster then using FileInfo or DirectoryInfo classes. It was developed to work with several millions of files.

Jul 1, 2010 at 11:50 AM

To my original question, will you still support XP?  I updated to the snapshot to get past an issue with setAttributes.  But we don't want to lose XP support in the process, so perhaps I need to roll back to the beta release, and then manually try to incorporate any fixes needed to get the setAttributes working?

Jul 1, 2010 at 3:31 PM
Chris, everything works fine in XP (i used it there for more than a
year), just don't use transacted versions of methods, those that don't
have a first parameter called "transaction".



On 1 July 2010 04:50, ChrisMachemer <notifications@codeplex.com> wrote:
> From: ChrisMachemer
>
> To my original question, will you still support XP?  I updated to the
> snapshot to get past an issue with setAttributes.  But we don't want to lose
> XP support in the process, so perhaps I need to roll back to the beta
> release, and then manually try to incorporate any fixes needed to get the
> setAttributes working?
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> ([email removed])
>
> To start a new discussion for this project, email
> [email removed]
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe or change your settings on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at codeplex.com



--
Sincerely,
Alexandr Normuradov