473,396 Members | 1,724 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,396 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 3227
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...

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.