VB.NET 2008 Validate File Extension

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lenniekuah
    New Member
    • Oct 2006
    • 126

    VB.NET 2008 Validate File Extension

    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
  • MrMancunian
    Recognized Expert Contributor
    • Jul 2008
    • 569

    #2
    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.FileI nfo. It works like this:

    Code:
    Dim fi As New System.IO.FileInfo("<path to file">
    Dim strExtension as String = fi.Extension()
    Steven

    Comment

    • lenniekuah
      New Member
      • Oct 2006
      • 126

      #3
      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

      Comment

      Working...