473,287 Members | 1,629 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,287 software developers and data experts.

Determine if "Hide extensions for known file types" is active

Is there a way, through VB.NET, to determine if the user has selected
this option? I am writing an application that does some string
functions to rename files, and the file names get chopped up if the
expected extension is not returned.

I can write another function to get around this, but if there is a
clean way to determine the state of that toggle I would rather do that.
I may need this again in the future and don't want to always write
custom string functions to get around it.

TIA.

- Luther

Nov 21 '05 #1
4 9690
Thats very interesting i didn't realise this setting had any effect. I
thought it affected the UI portion of Windows Explorer only, not the actual
output from the file system. Whatever the setting it will be in the
registry so you can check there. If your asking which registry key then Im
not sure but i reckon you could probably Google it in under 5 mins.

Richard
"lcifers" <lc*****@yahoo.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.com...
Is there a way, through VB.NET, to determine if the user has selected
this option? I am writing an application that does some string
functions to rename files, and the file names get chopped up if the
expected extension is not returned.

I can write another function to get around this, but if there is a
clean way to determine the state of that toggle I would rather do that.
I may need this again in the future and don't want to always write
custom string functions to get around it.

TIA.

- Luther

Nov 21 '05 #2
HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer\Advance
d

HideFileExt

0 = Show

1 = Hide

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #3
I use the below recursive routine to get a list of files in a directory and
it returns the extension as part of the file name in the List object even if
the "hide known file types" is checked:

Private Sub ListFiles(ByRef list As ArrayList, ByVal sPath As String,
ByVal searchpattern As String, ByVal returnpath As Boolean, ByVal chksubdir
As Boolean)
Dim di As System.IO.DirectoryInfo
Try
di = New System.IO.DirectoryInfo(sPath)
For Each fi As System.IO.FileInfo In di.GetFiles
If searchpattern = Nothing OrElse fi.Name.ToLower Like
searchpattern Then
If returnpath Then list.Add(fi.FullName) Else
list.Add(fi.Name)
End If
Next
If chksubdir Then
For Each diSub As System.IO.DirectoryInfo In di.GetDirectories
ListFiles(list, diSub.FullName, searchpattern,
returnpath, chksubdir)
Next
End If
Catch ex As Exception
list = Nothing
errmsg = ex.Message
errno = Err.Number
End Try
End Sub

"lcifers" wrote:
Is there a way, through VB.NET, to determine if the user has selected
this option? I am writing an application that does some string
functions to rename files, and the file names get chopped up if the
expected extension is not returned.

I can write another function to get around this, but if there is a
clean way to determine the state of that toggle I would rather do that.
I may need this again in the future and don't want to always write
custom string functions to get around it.

TIA.

- Luther

Nov 21 '05 #4
Just check against (read) the registry key I pasted before.

I must say your recursive routine is quite long

You don't need

errmsg = ex.Message
errno = Err.Number

because its already been checked using the Try - Catch - End Try block. You
could say:

MessageBox.Show(ex.ToString, Me.Text)

-------------------------------------------

Private Function IsExtensionShown() As Integer
Dim strKey As String = ""
Dim reg As RegistryKey
Dim intTemp As Integer

Try
reg = Registry.CurrentUser.OpenSubKey(strKey, True)
If Not (reg Is Nothing) Then
intTemp = reg.GetValue("HideFileExt")
End If
Catch ex As Exception
' Access denied error (security)
MessageBox.Show(ex.ToString)
Finally
If Not reg Is Nothing Then reg.Close()
End Try

Return intTemp

End Function

Return Values:
--------------

0 = Show File Extensions
1 = Hide File Extensions

--------------

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #5

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

Similar topics

4
by: Stephen Oakes | last post by:
I am trying to upload an image to a server, but I get this warning: Warning: imagecreatefromjpeg(): 'filename' is not a valid JPEG file The error occurs when I am trying to create a thumbnail...
2
by: | last post by:
I have a page where I have 3 combo boxes listed in a column. sort of like: combo1 combo2 combo3 Based on which one is clicked, the others are supposed to hide (i.e. combobox.visible =...
5
by: Nick | last post by:
Hi there, I despearately need to get IIS working with ASP.NET, but I still can't see any "Web Service Extensions". My previous question regarding this ended in the decision to uninstall .NET...
1
by: Terry Olsen | last post by:
I'm hoping someone can help me here. When trying to create a new web site with Visual Studio 2005, I choose HTTP and enter the url I want to create (http://MyWebServer/MyWebSite). But I get the...
0
by: Greg Larsen | last post by:
How add the "Active File" icon (down arrow), and the "Close" icon (X) next on TabPage in the gray space next to the tabs, so when I click on the X the active Tab closes, and and when I click on the...
3
by: Richard Rudie | last post by:
Anyone know of a proper .NET way to get the state of the user's "hide extensions for known file types" setting? Or should I read the value from the Registry directly...
3
by: deciacco | last post by:
I'm trying to write a label printing SDI app with a small preview on the main form itself. Every time I run the InvalidatePreview event on the preview control to redraw the preview I get the...
3
by: Akino877 | last post by:
Hello, I am trying to user a File Chooser with DIRECTORIES_ONLY set. And I would like to be able to hide the "Files of type" label and the associated combo box. I wonder if there is a way to do...
1
by: arme9867 | last post by:
i am using a formula in my subreport which goes like this: 'datediff("h",{VEHICLE.jo_datetime_created},{VEHICLE.jo_datetime_released}) but when i try to run the system it has a run time error...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.