473,407 Members | 2,326 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,407 software developers and data experts.

[VB.NET] Check a right filename...

HI....
In my vb.net project the user can insert into an imputbox a filename.
In what manner i can check the filename, so that will be accepted in a
Windows System? (i want that inside of the filename there isn't ";" , "*" ,
and all the charachters that windows doesn't accept...).I think is a bad
idea to use the Instr function for all that charachters.

I hope in your ideas.
from italy thank you.
Nov 21 '05 #1
1 1212
Hi,

You could use a regular expression for that. This example requires
the path so c:\test.txt will work but test.txt will not. Take a look at
regexlib.com for more examples.

Dim regFileName As New System.Text.RegularExpressions.Regex( _
"^([a-zA-Z]\:)(\\[^\\/:*?<>""|]*(?<![ ]))*(\.[a-zA-Z]{2,6})$")
Dim strOut As String = IIf(regFileName.IsMatch(TextBox1.Text), "Valid",
"Invalid").ToString
MessageBox.Show(strOut)

http://www.regexlib.com/REDetails.aspx?regexp_id=357
Ken
-----------------------
"tranky" <NO****@THANKY.YOU> wrote in message
news:fg*********************@news3.tin.it...
HI....
In my vb.net project the user can insert into an imputbox a filename.
In what manner i can check the filename, so that will be accepted in a
Windows System? (i want that inside of the filename there isn't ";" , "*" ,
and all the charachters that windows doesn't accept...).I think is a bad
idea to use the Instr function for all that charachters.

I hope in your ideas.
from italy thank you.

Nov 21 '05 #2

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

Similar topics

0
by: Namratha Shah \(Nasha\) | last post by:
Hi All, Assembly linker is a tool which is used to create an assembly by combining one or more .netmodules and resource files. In simple words an .netmodule is an IL file that does not have ...
3
by: Chris | last post by:
Hi, In C# I tried to save a file from a generated file name. Just before launching the dialog I check for a valid file name to be sure. There for I used the method ValidateNames from the save...
0
by: Namratha Shah \(Nasha\) | last post by:
Type Library Importer : tlbImp This tool is used to convert the type library definitons found in COM components to .NET assembly. This tool works on the entire type library at the same time...
20
by: J-T | last post by:
We are working on an asp.net application which is a 3-tier application.I was aksed to create a component which monitors a folder and gets the file and pass them to a class library in our business...
8
by: Sarah | last post by:
I need to access some data on a server. I can access it directly using UNC (i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network drive resource (S:\Path\FileName). Here is my...
1
by: Lloyd Dupont | last post by:
I never really use SQLExpress before... Anyway I'm trying to something a bit 'advanced' and I'm failing miserably. I have written a BlogEngin a while ago using SqlServer & ASP.NET 2.0 Beta 2 and...
9
by: craig.overton | last post by:
All, I am currently developing an FTP class in VB.NET. It's kid tested, mother approved when trying to access an FTP Server on a Windows box meaning I can connect, run commands, upload and...
0
by: shamirza | last post by:
· When was .NET announced? Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and...
3
by: premprakashbhati | last post by:
hi, good evening.. i am going to upload an image in a web form .....for that iam using HTML input(file) control and one web control button i.e., Upload_Button() here is the code ...its work fine...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
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...

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.