473,386 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Reading Encrypted File Attribute

Would anyone know how to read the file attributes of a file on the hard
drive to check if the file is encrypted or not? I have searched Visual
Studio Help and MSDN and the samples I have found do not work.

Any help would be appreciated.

I am using VB.NET

Nov 21 '05 #1
4 5503
"Debbie Carter" <dc*********@sbcglobal.net> schrieb:
Would anyone know how to read the file attributes of a file on the hard
drive to check if the file is encrypted or not?


\\\
Imports System.IO
..
..
..
If File.GetAttributes(FileName) And FileAttributes.Encrypted) =
FileAttributes.Encrypted Then
...
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
Hello Herfried,
Thank you for your help but I have been trying this and it does not
work. Any other suggestions? Here is the function I have been using. This is
in a module. It always returns a false.

Imports System.IO
Public Function CheckEncrypt(ByVal fname As String)

Dim eFlag As Boolean = False

If (File.GetAttributes(fname) And FileAttributes.Encrypted) =
FileAttributes.Encrypted Then

eFlag = True

End If

Return eFlag

End Function

The file is one that I saved with cryptostream. Am I suppose to set the
encryption attribute when saving? I have even tried setting it using
File.SetAttributes(fname, File.GetAttributes(fname) Or
FileAttributes.Encrypted)

but it did not work either.

Thank you,

Debbie

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
"Debbie Carter" <dc*********@sbcglobal.net> schrieb:
Would anyone know how to read the file attributes of a file on the hard
drive to check if the file is encrypted or not?


\\\
Imports System.IO
.
.
.
If File.GetAttributes(FileName) And FileAttributes.Encrypted) =
FileAttributes.Encrypted Then
...
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
"Debbie Carter" <dc*********@sbcglobal.net> schrieb:
I have been trying this and it does not
work. Any other suggestions? Here is the function I have been using. This
is
in a module. It always returns a false.

Imports System.IO
Public Function CheckEncrypt(ByVal fname As String)
The return value "should be" 'As Boolean' :-).
Dim eFlag As Boolean = False

If (File.GetAttributes(fname) And FileAttributes.Encrypted) =
FileAttributes.Encrypted Then

eFlag = True

End If

Return eFlag

End Function
'Encrypted' will only work if the encryption file attribute is set. It will
/not/ be set if the file /contains/ encrypted data, but it will be set if
the file /is/ encrypted.
The file is one that I saved with cryptostream. Am I suppose to set the
encryption attribute when saving? I have even tried setting it using
File.SetAttributes(fname, File.GetAttributes(fname) Or
FileAttributes.Encrypted)


ACK, this won't work. Documentation on 'File.SetAttributes' says "The
desired 'FileAttributes', such as 'Hidden', 'ReadOnly', 'Normal', and
'Archive'". From what I know, you will have to use p/invoke to set the
'Encrypted' file attribute. See (complete thread):

<URL:http://groups.google.de/groups?threadm=B78C26BF-B451-426F-9B84-4184892D5CF4%40microsoft.com>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4
Thank you Herfried for pointing me in the right direction.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:Ox****************@TK2MSFTNGP09.phx.gbl...
"Debbie Carter" <dc*********@sbcglobal.net> schrieb:
I have been trying this and it does not
work. Any other suggestions? Here is the function I have been using. This is
in a module. It always returns a false.

Imports System.IO
Public Function CheckEncrypt(ByVal fname As String)
The return value "should be" 'As Boolean' :-).
Dim eFlag As Boolean = False

If (File.GetAttributes(fname) And FileAttributes.Encrypted) =
FileAttributes.Encrypted Then

eFlag = True

End If

Return eFlag

End Function


'Encrypted' will only work if the encryption file attribute is set. It

will /not/ be set if the file /contains/ encrypted data, but it will be set if
the file /is/ encrypted.
The file is one that I saved with cryptostream. Am I suppose to set the
encryption attribute when saving? I have even tried setting it using
File.SetAttributes(fname, File.GetAttributes(fname) Or
FileAttributes.Encrypted)
ACK, this won't work. Documentation on 'File.SetAttributes' says "The
desired 'FileAttributes', such as 'Hidden', 'ReadOnly', 'Normal', and
'Archive'". From what I know, you will have to use p/invoke to set the
'Encrypted' file attribute. See (complete thread):

<URL:http://groups.google.de/groups?threa...-9B84-4184892D
5CF4%40microsoft.com>
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: raymondpendergraph | last post by:
I have a need to match security tags (signed keys) with certain other encrypted tags in the xml (certain keys to certain tags). There is also an attribute "Encrypted" which is a boolean in these...
3
by: Carl Lindmark | last post by:
*Cross-posting from microsoft.public.dotnet.languages.csharp, since I believe the question is better suited in this XML group* Hello all, I'm having some problems understanding all the ins and...
4
by: Andy | last post by:
Hello All: I have a field in the database that is an Image. I have no idea how the data is stored in here (Image, compressed, encrypted, plain text, etc). I am trying to write the contents to...
1
by: hzgt9b | last post by:
(FYI, using VB .NET 2003) Can someone help me with this... I'm trying to read in an XML file... it appears to work in that the DataSet ReadXML method dose not fail and then I am able to access the...
8
by: robert | last post by:
Hello, I want to put (incrementally) changed/new files from a big file tree "directly,compressed and password-only-encrypted" to a remote backup server incrementally via FTP,SFTP or DAV.... At...
5
by: Michael Sperlle | last post by:
Is it possible? Bestcrypt can supposedly be set up on linux, but it seems to need changes to the kernel before it can be installed, and I have no intention of going through whatever hell that would...
4
by: Pere Raphael | last post by:
Hi all, I am writng some code to read AD user properties but I am not having much luck reading octet values. For example, there is a property userPassword which returns System.Byte. When I...
3
by: Mir Mosharrof Hussain | last post by:
I am a PC user with very little technical knowledge. I will be very very thankful if you please go through my problem and give me a solution. Problem : File system was NTFS. OS was in...
10
by: wanni | last post by:
Hi All, I want to store data in a encypted form (in form of some file) and later on i want to read encrypted data in Java Script and want to pass that encrypted buffer to some Active X component. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.