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

VB.NET 2008 Validate File Extension

126 100+
Hullo Good Guys,
I have an intesting problem and I need your help. Please help me.

I am using Vb.NET2008 to develop Window Application. When the user enter the File Name on the textbox, I need to check the file name to ensure that it has the File Extension. (Eg. Sales.XLS) I have not done the coding before and stuggling with it.

Please help me with source coding.
Thank You.


Cheers,
Lennie
May 14 '11 #1
2 3231
MrMancunian
569 Expert 512MB
Do you want to check if an extension was manually entered in a textbox or do you want to check a file for an extension? In the first case, split the text in the textbox and use "." as splitcharacter and put it in an array. Check the last part of the array to determine the entered extension.

If you want to check the extension of a file, use the System.IO.FileInfo. It works like this:

Expand|Select|Wrap|Line Numbers
  1. Dim fi As New System.IO.FileInfo("<path to file">
  2. Dim strExtension as String = fi.Extension()
Steven
May 26 '11 #2
lenniekuah
126 100+
Hullo Good Guy MrMancunian
Thank you very much for sharing coding logic with me.
It's working now and awesome.

You are wonderful and Helpful.

Cheers,
Lennie
May 26 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Els | last post by:
If I use <? include "file.html"; ?> in the html of my document, do I _have_ to change the extension of that document to .php, or would it still work and be valid if I let it remain .html? --...
1
by: knutsample | last post by:
Hello! I'm trying to associate a file extension to my wxPython script so that all I have to do is double click on the file and my python script will load up with the path of that file. For...
1
by: john | last post by:
I have an exe console app that i wrote, which works on custom data files. I'd like to give these data files a custom extension and somehow register that file extension with my exe, so all i have to...
3
by: David | last post by:
Should you be able to map a any file extension to the ASP.NET dll and have it execute ASP.NET script, just like an .aspx page, when it is requested by a browser. If not, why bother giving us the...
7
by: Chris Kennedy | last post by:
Does anyone know a regular expression that will validate the file extension but also allow multiple file extensions if necessary. It also needs to be case insensitive. Basically, what I want is to...
1
by: Erik Cruz | last post by:
Hi. My application has a page where users can click on some links to download documents. When testing the page I noticed an strange behaviour. One of the links points to a .pps file. When I...
6
by: ad | last post by:
How can we assign file extension using FileUpload?
1
by: Just D. | last post by:
All, Who knows how can we make the IE open the file with some non-standard extension? I have a new file type, say .MOX, I corrected the association on my computer for this file extension,...
2
by: gyanendar | last post by:
Hi , I want to validate the file extension (.pdf) in through "RegularExpressionValidator" (asp.net) .I am not able to decide what ValidationExpression shall i use. Please help. Manohar
2
by: dazzler | last post by:
I need to open PDF file with my python application, and I'm using os.startfile(filename.pdf) command, I would need open command act 100% like clicking the file in the windows explorer python...
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:
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,...
0
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
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...

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.