Multimobile Development: Building Applications for any Smartphone
How to access NTFS streams?
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.sdk.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Rado Mroz
GOOD ANSWER
On Beta 2 I was able to access NTFS streams. I.e.,
File.Exists("d:\\filename:AFP_Resource") returned true.

:AFP_Resource, :AFP_AfpInfo and :Comments are 3 streams where Mac File
Services store Macintosh file forks. The file I check is on NTFS partition
and has given stream (I checked in command prompt with 'more
<filename:AFP_Resource')

However, in final version of SDK I cannot access NTFS streams. File,
FileInfo and FileStream classes throw System.NotSupportedException
('Additional information: The given path's format is not supported').

Is there any way to access those NTFS streams (preferably C#)?

Thanks,

Rado

Reply to this message...
Vote that this is a GOOD answer... (3 votes from other users already)
 
 
    
Willy Denoyette [MVP] (VIP)
GOOD ANSWER
NTFS Streams are not supported, but you can get access to them using PInvoke.

Willy.

"Rado Mroz" <Click here to reveal e-mail address> wrote in message news:ON7T$XeuBHA.1892@tkmsftngp03...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (3 votes from other users already)
 
 
    
Rado Mroz
GOOD ANSWER
Just one more question - how do you know NTFS streams are not supported?
They were supported in Beta 2 and the list of API changes doesn't mention
it.

Rado

"Willy Denoyette [MVP]" <Click here to reveal e-mail address> wrote in message
news:u480RmiuBHA.1596@tkmsftngp07...
> NTFS Streams are not supported, but you can get access to them using
PInvoke.
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (3 votes from other users already)
 
 
    
Willy Denoyette [MVP] (VIP)
GOOD ANSWER
This is a quote from Chris Anderson (FX DEV) Microsoft.
<<
Due to our string based file name comparison model, file name aliasing presents a major and complicated issue. This complexity is
increased by the operating system's ability to use pluggable file systems. Therefore, to reduce the scope of this issue we do not
support some features of certain file systems. This currently includes NTFS streams. The full range of OS supported file
operations is still available via P/Invoke to the appropriate APIs.

Chris Anderson
This posting is provided "AS IS" with no warranties, and confers no rights.
>>

Willy.

"Rado Mroz" <Click here to reveal e-mail address> wrote in message news:e7rj43kuBHA.1020@tkmsftngp07...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (3 votes from other users already)
 
 
    
Rado Mroz
GOOD ANSWER
Thanks,

Rado

"Willy Denoyette [MVP]" <Click here to reveal e-mail address> wrote in message
news:evMiJDsuBHA.1608@tkmsftngp04...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (4 votes from other users already)
 
 
    
Rado Mroz
GOOD ANSWER
How? Where can I find more info?

Rado

"Willy Denoyette [MVP]" <Click here to reveal e-mail address> wrote in message
news:u480RmiuBHA.1596@tkmsftngp07...
> NTFS Streams are not supported, but you can get access to them using
PInvoke.
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (3 votes from other users already)
 
 
    
Willy Denoyette [MVP] (VIP)
GOOD ANSWER
Here is a small sample how to check for the presence of a Multi stream file.

Check the MSDN doc's on deatail about PInvoke.

using System;
using System.Runtime.InteropServices;
class TestNTFSStream
{
[DllImport("kernel32.dll")]
public static extern IntPtr CreateFile( string lpFileName, int dwDesiredAccess, int dwShareMode,
IntPtr lpSecurityAttributes, int dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile );
// some constants see Platform-SDK for others

private const int FILE_SHARE_READ = 1;
private const int OPEN_EXISTING = 3;
private const int INVALID_HANDLE_VALUE = -1;

static void Main(string[] args)
{
//Try to open the file for read only
IntPtr hflp = CreateFile( @"c:\filename:AFP_Resource", 0, FILE_SHARE_READ, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero );
if( (int)hflp == INVALID_HANDLE_VALUE )
Console.WriteLine("No such file/stream");
else
Console.WriteLine("File found");
}

}

Willy.

"Rado Mroz" <Click here to reveal e-mail address> wrote in message news:enGdIFjuBHA.2156@tkmsftngp02...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (3 votes from other users already)
 
 
    
Rado Mroz
GOOD ANSWER
I've got it working again.

Thanks,

Rado

"Willy Denoyette [MVP]" <Click here to reveal e-mail address> wrote in message
news:Owm#u6kuBHA.1460@tkmsftngp05...
> Here is a small sample how to check for the presence of a Multi stream
file.
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (4 votes from other users already)
 
 
 
System.Console
System.IntPtr
System.IO.File
System.IO.FileInfo
System.IO.FileStream
System.NotSupportedException




Multimobile Development: Building Applications for any Smartphone
Ad
BootFX
Reliable and powerful .NET application framework.
iOS, Android and Windows Phone Development Training and Consultancy
Hosted by RackSRV Communications
 
Multimobile Development: Building Applications for any Smartphone
Copyright © AMX Software Ltd 2008-2010. Portions copyright © Matthew Baxter-Reynolds 2001-2010. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - 4.0.30129.1734