|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Create and delete an unreadable file in c#Hello, is it possible in C# to create a file which is unreadable (i.e.
no program can open it at all) and also at a later point to delete it? Thanks in advance. Hello, elgdav!
e> Hello, is it possible in C# to create a file which is unreadable (i.e. e> no program can open it at all) and also at a later point to delete it? e> Thanks in advance. create file, set access control to deny access for all users, before deleting the file set required access control to delete the file. Only admin will be able to delete the file. Why do you need such functionality? Thanks for the reply Vadym,
I'll use File.Create(string path) to create the file but what method should I use to set the access control? I am going to use the functionality to test a program I am developing which is a bit like Windows Explorer. I need to check its capability to handle an unreadable file. Vadym Stetsyak wrote: Show quote > Hello, elgdav! > > e> Hello, is it possible in C# to create a file which is unreadable (i.e. > e> no program can open it at all) and also at a later point to delete it? > e> Thanks in advance. > > create file, set access control to deny access for all users, before deleting the file set required access control > to delete the file. Only admin will be able to delete the file. > > Why do you need such functionality? > > -- > Regards, Vadym Stetsyak > www: http://vadmyst.blogspot.com Hello, elgdav!
e> I'll use File.Create(string path) to create the file but what method e> should I use to set the access control? File.SetAccessControl(...). Take a look at ( http://msdn2.microsoft.com/en-us/library/system.io.file.setaccesscontrol.aspx ) for method docs. And here ( http://west-wind.com/weblog/posts/4072.aspx ) for the example howto set ACL ( access control lists ) on files. e> I am going to use the functionality to test a program I am developing e> which is a bit like Windows Explorer. I need to check its capability to e> handle an unreadable file. You can create such a file with the help of ordinary explorer and then manually set ACL on it. Test your application and then modify ACL and delete the file... Thanks for your reply Vadym,
> You can create such a file with the help of ordinary explorer and then manually set ACL on it. This test needs to be automated and repeatable so has to be done by> Test your application and then modify ACL and delete the file... software. > Take a look at ( http://msdn2.microsoft.com/en-us/library/system.io.file.setaccesscontrol.aspx ) These are .Net version 2 solutions, I am using version 1.1 (sorry I was> for method docs. And here ( http://west-wind.com/weblog/posts/4072.aspx ) > for the example howto set ACL ( access control lists ) on files. late telling you that) Thanks for all your help, do you know of any way to accomplish this in version 11 of the framework? cheers elgdav Vadym Stetsyak wrote: Show quote > Hello, elgdav! > > e> I'll use File.Create(string path) to create the file but what method > e> should I use to set the access control? > > File.SetAccessControl(...). > Take a look at ( http://msdn2.microsoft.com/en-us/library/system.io.file.setaccesscontrol.aspx ) > for method docs. And here ( http://west-wind.com/weblog/posts/4072.aspx ) > for the example howto set ACL ( access control lists ) on files. > > e> I am going to use the functionality to test a program I am developing > e> which is a bit like Windows Explorer. I need to check its capability to > e> handle an unreadable file. > > You can create such a file with the help of ordinary explorer and then manually set ACL on it. > Test your application and then modify ACL and delete the file... > > -- > Regards, Vadym Stetsyak > www: http://vadmyst.blogspot.com Hello, elgdav!
e> Thanks for all your help, do you know of any way to accomplish this in e> version 11 of the framework? See my answer below I've noticed that File.SetAccessControl exists in .Net 2.0 but i need
this to be in Version 1.1 Thanks for any help Vadym Stetsyak wrote: Show quote > Hello, elgdav! > > e> Hello, is it possible in C# to create a file which is unreadable (i.e. > e> no program can open it at all) and also at a later point to delete it? > e> Thanks in advance. > > create file, set access control to deny access for all users, before deleting the file set required access control > to delete the file. Only admin will be able to delete the file. > > Why do you need such functionality? > > -- > Regards, Vadym Stetsyak > www: http://vadmyst.blogspot.com Hello, elgdav!
Then you will have to use native API and P/Invoke to set ACLs. Take a look at ( http://www.codeproject.com/dotnet/SecureRegistryKey.asp ) Although this articles talks about registry keys, the same is valid for files ( in the ACL context ) "Vadym Stetsyak" <vady***@ukr.net> wrote in message Actually you should create the file with the ACL in one step by p/invoke news:e4oxStczGHA.4648@TK2MSFTNGP04.phx.gbl... > Hello, elgdav! > > Then you will have to use native API and P/Invoke to set ACLs. > > Take a look at ( http://www.codeproject.com/dotnet/SecureRegistryKey.asp ) > > Although this articles talks about registry keys, the same is valid for > files ( in the ACL context ) CreateFile API and supply the security descriptor. Use a permission of: CREATOR/OWNER => Delete Show quote "elgdav" <elgandav***@hotmail.com> wrote in message Even garbage can be read by something, even if it has to be a hex editor. news:1157114929.922873.317720@m73g2000cwd.googlegroups.com... > Hello, is it possible in C# to create a file which is unreadable (i.e. > no program can open it at all) So, no, you cannot create a file that cannot be read by anything. Can you create random garbage? Yes. Can you create encrypted files that a person cannot steal information from? Yes. Can you make it absoluletely impossible for anyone to read it no matter what effort they put into it? No, esp. if you put it on their machine. > and also at a later point to delete it? Yes, you can delete files that you create, garbage or otherwise.Hope this helps! -- Gregory A. Beamer MVP; MCP: +I, SE, SD, DBA ************************************************* Think outside of the box! ************************************************* Thanks for your reply cowboy, we might have our wires crossed here, I
don't want to encrypt the file i just want to set it so it is not read accessable, in the same way as you can make a file not writeable, if that makes sense. Cowboy (Gregory A. Beamer) wrote: Show quote > "elgdav" <elgandav***@hotmail.com> wrote in message > news:1157114929.922873.317720@m73g2000cwd.googlegroups.com... > > Hello, is it possible in C# to create a file which is unreadable (i.e. > > no program can open it at all) > > Even garbage can be read by something, even if it has to be a hex editor. > So, no, you cannot create a file that cannot be read by anything. Can you > create random garbage? Yes. Can you create encrypted files that a person > cannot steal information from? Yes. Can you make it absoluletely impossible > for anyone to read it no matter what effort they put into it? No, esp. if > you put it on their machine. > > > and also at a later point to delete it? > > Yes, you can delete files that you create, garbage or otherwise. > > Hope this helps! > > > -- > Gregory A. Beamer > MVP; MCP: +I, SE, SD, DBA > > ************************************************* > Think outside of the box! > *************************************************
Other interesting topics
|
|||||||||||||||||||||||