.NET Framework Bookmark and Share   
 index > Common Language Runtime > How can I hide text files
 

How can I hide text files

I am using MS V S 2008. I am working with files. Something likes this

FileStream^ fs =

new FileStream( "_1Name.txt",FileMode::OpenOrCreate);

new StreamWriter(fs); // Create a StreamWriter

sw->Write(strng);

sw->Flush();

sw->Close();


Now I noticed that the files Iam working with such as
"_1Name.txt",can beaccessed and modified by anyone who can go to"My computer". How can I hidethose filesor makethem visible but inaccessible(May be giving them extensions not "*.txt" )?

Allen_Press
Your application needs to read/write a txt file, andyou want to prevent others from accessing/modifying the file, am i right?
If so, some ideas for you:
1. Put the file in your application folder if possible to tell others that "don't modify or move the file, it is a part of the application.".
2. Encrypt the file when write operation is done, decrypt itbefore read operation,following aresome helpful links about Encrypt/Decrypt file:
http://www.codeproject.com/KB/security/fileencryptdecrypt.aspx;
http://www.codeproject.com/KB/security/DotNetCrypto.aspx;
http://support.microsoft.com/kb/307010;
3. There are some smart softwares have the abliity to hide file/folder, but those kits mayalso make the file inaccessible to your application.

Thanks,
Eric

Please remember to mark helpful replies as answers and unmark them if they provide no help.
eryang
To prevent anyone from reading the file, make sure you press Windows + L whenever you leave your desk.
Hans Passant.
nobugz
Your application needs to read/write a txt file, andyou want to prevent others from accessing/modifying the file, am i right?
If so, some ideas for you:
1. Put the file in your application folder if possible to tell others that "don't modify or move the file, it is a part of the application.".
2. Encrypt the file when write operation is done, decrypt itbefore read operation,following aresome helpful links about Encrypt/Decrypt file:
http://www.codeproject.com/KB/security/fileencryptdecrypt.aspx;
http://www.codeproject.com/KB/security/DotNetCrypto.aspx;
http://support.microsoft.com/kb/307010;
3. There are some smart softwares have the abliity to hide file/folder, but those kits mayalso make the file inaccessible to your application.

Thanks,
Eric

Please remember to mark helpful replies as answers and unmark them if they provide no help.
eryang
Try writing a small app that open your files exclusively. This program would always be running. You can also make this program password protected.

when ever you want to access your files, close your program so that it would release the file handles.
Sandy Kumar 2008
These are not effective security measures. Anybody that can get to your work station can kill a program or run a debugger to bypass the protection. Press Windows + L for real protection.
Hans Passant.
nobugz
Try writing a small app that open your files exclusively. This program would always be running. You can also make this program password protected.

when ever you want to access your files, close your program so that it would release the file handles.

I would like to explain that the files are going to be inside the folder. If you open the folders of any program say windows xp. You may find a lot of files of different extensions. If you try to open any of them you cannot, but if there is a file end with .txt; I think anybody can open such as Ream me files. Imagine if I do not want anybody to open that Read me file.

Allen_Press
Eric,
I think you understood me very well. Thanks I will review those sites. To make it clearer. Imagine that I donot want anybody to read the Read me files.
Allen_Press
Hans,
It is off the wall, but still can use it!
Allen_Press

The instruction

File.SetAttributes(@"c:\yourfile.xyz", FileAttributes.Hidden)

hidden the file.
Livio_75
Iapprciate it. Do you think it will work with MS VS C++ 2008?
Allen_Press

You can use google to search for other answers

Custom Search

More Threads

• Event Log Problem
• CAS and NamedPermissionSet.PermitOnly
• Memory Intensive Process Management
• what's the difference ????
• Optimizing performance with GC
• P/Invoke and 'access violation' in target DLL
• Install GACUTIL 3.5 on machine without Visual Studio?
• can we create Native image of a strong name assembly ? If yes,please give me full details....
• RSACryptoServiceProvider to encrypt/decrypt with non-XML keys
• interop failure returning array of objects wrapped in DispatchWrappers to COM client