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

Browse and Store Filename

Bob
Greetings!

I need to use the windows browse dialog to select and store a
fileaname.

I can get the filename with the path no problem. But I ONLY want to
return the filename.

Does anyone know how I can just return the filename?

Thanks!

Bob

Dec 5 '05 #1
3 2002
Bob
I got it.

I took the returned path and just used:

Dir(returnedPath)

Jeez... Should have known that one!

Dec 5 '05 #2
On 5 Dec 2005 11:50:46 -0800, "Bob" <st***********@hotmail.com> wrote:
I got it.
I took the returned path and just used:
Dir(returnedPath)
Jeez... Should have known that one!


Another way to do this (with out the Dir function, which can cause
some interesting results when used in a loop) is to use the
PathFindFileName API call in shlwapi.dll:

Private Declare Function PathFindFileName _
Lib "shlwapi" _
Alias "PathFindFileNameA" _
(ByVal pPath As String) _
As Long
Private Declare Function lstrcpyA _
Lib "kernel32" _
(ByVal RetVal As String, _
ByVal ptr As Long) _
As Long
Private Declare Function lstrlenA _
Lib "kernel32" _
(ByVal ptr As Any) _
As Long
Private Function GetStrFromPtrA(ByVal lpszA As Long) As String
GetStrFromPtrA = String$(lstrlenA(ByVal lpszA), 0)
Call lstrcpyA(ByVal GetStrFromPtrA, ByVal lpszA)
End Function
Public Function GetFilePart(ByVal sPath As String) As String
GetFilePart = GetStrFromPtrA(PathFindFileName(sPath))
End Function
--
Drive C: Error. (A)bort (R)etry (S)mack The Darned Thing

Dec 5 '05 #3
Chuck Grimsby <c.*******@worldnet.att.net.invalid> wrote in
news:uf********************************@4ax.com:
On 5 Dec 2005 11:50:46 -0800, "Bob"
<st***********@hotmail.com> wrote:
I got it.
I took the returned path and just used:
Dir(returnedPath)
Jeez... Should have known that one!


Another way to do this (with out the Dir function, which can
cause some interesting results when used in a loop) is to use
the PathFindFileName API call in shlwapi.dll:


Another way is to take the returned string and

x = len(fullfilename)
for x = len(fullfilename to 1 step -1
if mid(fullfilename,x,1) = "\" then exit for
next
directorypath = left(fullfilename,x)
shortfilename = mid(fullfilename,x+1)

--
Bob Quintal

PA is y I've altered my email address.
Dec 5 '05 #4

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

Similar topics

6
by: Jane Doe | last post by:
Hi, I need to add a download function in a VB program, but since a file can be located anywhere in our /download section on the web, I was thinking of putting a PHP script there that would take...
21
by: strutsng | last post by:
<input type="file"> only allows the user to browse for files. How about "browse for folder" dialog? Can html/javascript do that? I couldn't find any syntax for that. If not, please advise what...
5
by: Rob | last post by:
Help me, I'm just beginning with programming in Access 2000. I've tried the http://www.mvps.org/access/api/api0001.htm but it won't work in Access. What am i doing wrong. I don't have...
5
by: Dan | last post by:
I am working on a C# ASP.NET project where I need to allow the user to browse to a folder. The only way I see how to do this is use <input type=file>. But this makes the user select a file and...
3
by: Wardeaux | last post by:
Hey all, need sample/article how to let user browse local drives to select a file and have the local drive location returned so I can store it in my db, similar to a file upload but without the...
3
by: UJ | last post by:
How can I add a browse button to my asp.net page? What I need is a button they can press that will then let them select the file to upload to the server. And if anybody has any good code on how...
5
by: Mike Moore | last post by:
I need to create something very similiar to the browse folder capability. This would allow me to support the following - A user would create a document on their server, then they would need to...
1
by: Bob | last post by:
Greetings! I need to use the windows browse dialog to select and store a fileaname. I can get the filename with the path no problem. But I ONLY want to return the filename. Does anyone...
10
by: Paul Cheetham | last post by:
Hi, I am developing an application that needs to store some machine-specific settings. The application is going to be published on the network in order to keep the clients on the latest version....
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
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...
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
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: 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.