Hi, I'm trying tot write an App that runs through the system just reading files and producing a hash of each file. The problem is that certain files in the CE file system are protected and I can't seem to read from them. The Exception occured in these lines;
private string GetHash(BinaryReader br, int SizeOfFile){
byte[] hash; ASCIIEncoding enc = new ASCIIEncoding(); byte[] buffer = new byte[SizeOfFile];br.Read(buffer, 0, SizeOfFile);
}
From what I was getting from Visual studio suggeted I did something like the following:
using
System.Security;using
System.Security.Permissions;[assembly:FileIOPermission(SecurityAction.RequestOptional, Unrestricted =
true)]
I added this to my file, but now I get the following error:
Error 1 The type or namespace name 'FileIOPermission' could not be found (are you missing a using directive or an assembly reference ) C:\Documents and Settings\Joshua\My Documents\Visual Studio 2005\Projects\DiffCheckClient\DiffCheckClient\Form1.cs 17 11 DiffCheckClient
Is there something I'm doing wrong

FileIOPermission issue
Wee Bubba
Chuck Cobb
It might appear so until you count in files in ROM might be “pre-digested” to support XIP.
By the way, what happens if you can try to, say, copy that file with explorer
Rodolfo Caporale
There's no FileIOPermission on device. In fact, there's no CAS at all, so it won't help and not why you see this issue. OS simply won't allow you to open files witch are already opened in none share mode, so you should skip these.
Fippy
How come it doesn't throw the exception when I open the file then in this case the exception is being thrown when I try to read from it. They shouldn't give me a handle to the file if the file is locked. Right
asiaindian
well you can open a file but when you attempt to do some operations, like read in this case, it will throw an error as the file would be in use, meaning, the owner of the file who is using it has not set the file to be sharable for others to read/write to it.
Mike Berro
you can check to see if the file is a system file using the FileInfo.Attributes class/property in the System.IO namespace
I'm unsure if this property/attribute is available in the .NET CF, but only in the full version of the framework (for the PC)
Again, don't quote me! :-)
djdotti
/windows/iexplore.exe is one of the ones that jumped out at me.
I'm getting a valid Filestream handle, and binary reader. Its only when I try to read from the binary reader it throws an exception
Diango
Are you sure it's actually opened Which file is that
niallhannon
As far as I remember native executables and DLLs in ROM are treated specially, perhaps that's the reason why you can not read from file even though you can open it.