473,465 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Finding the extension of a file

vdraceil
236 New Member
Hi,does anyone know how to find the extension of a file knowing only the name of the file?to be more clear,i want to know the extension of some file with its path and file name-"C:\folder\file"..How do i do it by coding in vb6.0?
Feb 10 '08 #1
3 13403
mafaisal
142 New Member
Hello,

Try The Following

Dim ExtName as string
Dim FileName as string
FileName = "Test.Txt" ' for example

ExtName = Mid(FileName ,InStrRev(FileName , ".")+1, Len(FileName ))

then got ExtName = "Txt"

If not this plz ignore

Faisal
Feb 10 '08 #2
vdraceil
236 New Member
Hello,

Try The Following

Dim ExtName as string
Dim FileName as string
FileName = "Test.Txt" ' for example

ExtName = Mid(FileName ,InStrRev(FileName , ".")+1, Len(FileName ))

then got ExtName = "Txt"

If not this plz ignore

Faisal
Hi mafaisal,i think u didnt get my question.U've just taken FileName="Test.txt".My question was if i know a file name(just the name and not its extension) and its correct path,can i find its extension using VB6.0?.Take FileName="C:\Folder\File".I want to find the extension of the file "File".
Feb 22 '08 #3
mafaisal
142 New Member
Hello
Ok Understand

Try this

Add reference microsoft scripting runtime

Expand|Select|Wrap|Line Numbers
  1. Dim FSO As New FileSystemObject
  2. Dim F1 As File
  3. Dim FOL As Folder
  4. Set FOL = FSO.GetFolder(Path of File)
  5. Dim Ext
  6. For Each F1 In FOL.Files
  7.  Ext = Split(F1.Name, ".")
  8.  MsgBox Ext(1)
  9. Next
  10.  
  11.  

Hope this will Help u

Faisal

Hi mafaisal,i think u didnt get my question.U've just taken FileName="Test.txt".My question was if i know a file name(just the name and not its extension) and its correct path,can i find its extension using VB6.0?.Take FileName="C:\Folder\File".I want to find the extension of the file "File".
Feb 22 '08 #4

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

Similar topics

5
by: hokiegal99 | last post by:
Hi, I have a working Python script that renames files that don't currently have PC based file extensions. For example, if there is a MS Word file that does not have '.doc' on the end of it, the...
13
by: yaipa | last post by:
What would be the common sense way of finding a binary pattern in a ..bin file, say some 200 bytes, and replacing it with an updated pattern of the same length at the same offset? Also, the...
3
by: Jonny | last post by:
Hi all, I need to find out the hex value of a file. Is this possible? I need to be able to quickly access and confirm its extension against its file type (which is as far as i know defined by its...
1
by: Aaron via DotNetMonster.com | last post by:
I am testing for several file types in a directory by creating an array of masks and for each mask in the array, I execute a GetFiles. My issue is that the VB code: ...
1
by: Brian Henry | last post by:
Just thought maybe someone here would like to know this. It's an example code I just created quickly on how to figure out the name of a type of file based on its extension (say for example .DOC)...
3
by: Alexander van Doormalen | last post by:
I have a windows service which calls extensions. In 1 of those extensions I want to load a config file (extension.dll.config). In that config file I defined some ConfigurationSection's. For...
4
by: Ivan Bernage | last post by:
Hello, My problem: In a VB6-program I would like to find the path to the program associated to a given extension. E.g. given the extension *.doc I would like to find the path to winword.exe...
12
by: Jeff | last post by:
As I'm learning PHP, I'm making a fair number of mistakes in syntax. In perl, you can turn on reading these errors from the browser by adding this: use CGI::Carp 'fatalsToBrowser'; Is there...
5
by: mohi | last post by:
hello everyone i m positing this again but can't help as im not finding any solution to this . my problem is i have to browse a directory to search for all the files in it and process certain...
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
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.