472,333 Members | 1,068 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,333 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 9596
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...
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...
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...
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...
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...
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...
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...
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...
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...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

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.