473,803 Members | 3,857 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9725
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******** *************@l 41g2000cwc.goog legroups.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_US ER\Software\Mic rosoft\Windows\ CurrentVersion\ Explorer\Advanc e
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.Direc toryInfo
Try
di = New System.IO.Direc toryInfo(sPath)
For Each fi As System.IO.FileI nfo In di.GetFiles
If searchpattern = Nothing OrElse fi.Name.ToLower Like
searchpattern Then
If returnpath Then list.Add(fi.Ful lName) Else
list.Add(fi.Nam e)
End If
Next
If chksubdir Then
For Each diSub As System.IO.Direc toryInfo In di.GetDirectori es
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 IsExtensionShow n() As Integer
Dim strKey As String = ""
Dim reg As RegistryKey
Dim intTemp As Integer

Try
reg = Registry.Curren tUser.OpenSubKe y(strKey, True)
If Not (reg Is Nothing) Then
intTemp = reg.GetValue("H ideFileExt")
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
19394
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 from the image. I can subsequently display the JPG image itself, but the thumbnail creation fails. I have tried this with hundreds of other images from the same source and they work fine. I have looked around on Google and it seems that others...
2
2220
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 = false). However, when I have the bottom one in that column to be the one to be used
5
2189
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 Framework 1.1 then reinstall, unfortunately this seems to have done nothing. I've tried calling aspnet_regiis in a number of ways but that seems to do nothing either, even though it says that uninstallation and installation completes...
1
6467
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 following error: Unable to create the web 'http://MyWebServer/MyWebSite'. Server error: the server extensions were unable to access the file 'frontpg.lck'. Please check the file permissions. I googled it and only found suggestions for...
0
1436
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 down arrow the All active tabs are displayed.
3
2367
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 (HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\HideFileExt)?
3
8856
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 "Generating Previews" dialog box while the preview is being generated. I want to suppress this. I've been able to find this from another forum: "The 'Generating Previews' dialog is shown while calculating the layout for pages in OnPaint(). One of our...
3
3695
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 this programmatically or by using NetBeans? Thank you for your help. Akino.
1
9095
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 which goes like this: This field name is not known. Error in File C:\DOCUME~1\AMALIN~1\LOCALS~1\Temp\VehicleEfficiencyByVehicleTypeWithBusinessGroup {2A589B55-85CD-4DBE-B90B-AF181A380C8C}.rpt: Error in formula ....
0
10546
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10068
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7603
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6841
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.