18a32 STrip path of a file
Sign Up |  Live StatsLive Stats    Articles 37,330| Comments 177,267| Members 19,415, Newest GP Kaur| Online 521
Home Contact
 (Forgotten?): 
    Sikhism
    For best SPN experience, use Firefox Internet Browser!


                                                                   Your Banner Here!    




Click Here to Register/Sign Up Daily Hukamnama Member Blogs Downloads Website Navigation Help Fonts Tags

STrip path of a file

Our Donation Goal : Why Donate? : Donate Today! : Donate Anonymously (ਗੁਪਤ) : Our Family of Supporters
Goal this month: 500 USD, Received: 115 USD (23%)
Please Donate...
     
Related Topics...
Thread Thread Starter Forum Replies Last Post
Cops Appeal for Help in Strip Mall Murder (North York, CA) spnadmin Community Out-Reach 0 11-Feb-2011 03:56 AM
KPS Gill a convict, strip him of Padma Shri: Rupan Deol Narayanjot Kaur Hard Talk 1 14-Feb-2010 11:46 AM
Why do we do path or listen to path ddhillon Sikh Sikhi Sikhism 16 10-Dec-2006 15:19 PM
Error 75....Path/File access error... Bob Barnes Information Technology 5 28-Jul-2006 08:29 AM
How to strip out non numeric characters in a query tom Information Technology 17 28-Jul-2006 08:26 AM


Tags
strip, path, file
Reply Post New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!
  #1 (permalink)  
Old 28-Jul-2006, 08:16 AM
SF's Avatar SF
Guest
 
Posts: n/a
   
   
STrip path of a file

  Donate Today!   Email to Friend  Tell a Friend   Show Printable Version  Print   Contact sikhphilosophy.net Administraion for any Suggestions, Ideas, Feedback.  Feedback  

Register to Remove Advertisements
Hi,

I have file eg G:\MYPICTURES\123456.JPG

What is the function to strip the PATH (eg G:\MYPICTURES\) out of the enture
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/information-technology/10777-strip-path-of-a-file.html
string?

SF



*







Got anything to share on This Topic? Why not share your immediate thoughts/reaction with us! Login Now! or Sign Up Today! to share your views... Gurfateh!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 28-Jul-2006, 08:16 AM
strive4peace's Avatar strive4peace
Guest
 
Posts: n/a
   
   
Re: STrip path of a file

If the file exists, you can do this:

'~~~~~~~~~~~~~
dim mPath as string, mFile as string
dim mSpec as string

mSpec = "G:\MYPICTURES\123456.JPG"

mFile = DIR(mSpec)

mPath = left(mSpec, _
len(mSpec)-len(mfile))
'~~~~~~~~~~~~~


if you do not know if the file exists...

'~~~~~~~~~~~~~
Function GetPath( _
pSpec as string) _
as String

dim mPath as string, i as integer
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10777

i = len(mSpec)

for i = len(mSpec) to 1 step -1
if mid(pSpec,i,1) = "\") then
GetPath = _
left(pSpec, i)
exit function
end if
next i

End Function

'~~~~~~~~~~~~~


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day

remote programming and training
strive4peace2006 at yahoo.com

*

SF wrote:
> Hi,
>
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10777
> I have file eg G:\MYPICTURES\123456.JPG
>
> What is the function to strip the PATH (eg G:\MYPICTURES\) out of the enture
> string?
>
> SF
>
>

Reply With Quote
  #3 (permalink)  
Old 28-Jul-2006, 08:16 AM
Steve Schapel's Avatar Steve Schapel
Guest
 
Posts: n/a
   
   
Re: STrip path of a file

SF,

Mid([YourField],InStrRev([YourField],"\")+1)

--
Steve Schapel, Microsoft Access MVP

SF wrote:
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10777
> Hi,
>
> I have file eg G:\MYPICTURES\123456.JPG
>
> What is the function to strip the PATH (eg G:\MYPICTURES\) out of the enture
> string?
>
> SF
>
>

Reply With Quote
  #4 (permalink)  
Old 28-Jul-2006, 08:16 AM
Dirk Goldgar's Avatar Dirk Goldgar
Guest
 
Posts: n/a
   
   
Re: STrip path of a file

"SF" wrote in message
news:euh0073hGHA.1864@TK2MSFTNGP02.phx.gbl
> Hi,
>
> I have file eg G:\MYPICTURES\123456.JPG
>
> What is the function to strip the PATH (eg G:\MYPICTURES\) out of the
> enture string?


If the file exists, you can use this simple function:

'----- start of code -----
Function PathOnly(FullFilePath As String) As String

PathOnly = _
Left(FullFilePath, _
Len(FullFilePath) - Len(Dir(FullFilePath)))
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10777

End Function

'----- end of code -----

If the file doesn't exist, you need to do a bit more work:

'----- start of code #2 -----
Function PathOnly2(FullFilePath As String) As String

'Use this version if the file may not exist.

Dim I As Long

I = InStrRev(FullFilePath, "\")
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10777

If I = 0 Then
I = InStrRev(FullFilePath, ":")
End If

If I = 0 Then
PathOnly2 = FullFilePath
Else
PathOnly2 = Left(FullFilePath, I)
End If

End Function
'----- end of code #2 -----

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Reply With Quote
  #5 (permalink)  
Old 28-Jul-2006, 08:16 AM
strive4peace's Avatar strive4peace
Guest
 
Posts: n/a
   
   
Re: STrip path of a file

thanks, Steve ... forgot about InStrRev ... old habits die hard!


Warm Regards,
Crystal
Microsoft Access MVP 2006
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10777

*
Have an awesome day

remote programming and training
strive4peace2006 at yahoo.com

*

Steve Schapel wrote:
> SF,
>
> Mid([YourField],InStrRev([YourField],"\")+1)
>

Reply With Quote
  #6 (permalink)  
Old 28-Jul-2006, 08:16 AM
Steve Schapel's Avatar Steve Schapel
Guest
 
Posts: n/a
   
   
Re: STrip path of a file

Well, looks like I may have misinterpreted your question. I assumed
that after a "strip", the interest is more on what's left rather than on
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10777
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10777
what's removed ;-). In any case, even with my interpretation, a simple
Dir([YourField]) would have sufficed. Oh well...

--
Steve Schapel, Microsoft Access MVP


Steve Schapel wrote:
> SF,
>
> Mid([YourField],InStrRev([YourField],"\")+1)
>

Reply With Quote
  #7 (permalink)  
Old 28-Jul-2006, 08:16 AM
strive4peace's Avatar strive4peace
Guest
 
Posts: n/a
   
   
Re: STrip path of a file

Hi Steve,

you're not the only one ... now that you mention it, the
question could be interpreted 2 ways...
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10777

Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10777

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day

remote programming and training
strive4peace2006 at yahoo.com

*

Steve Schapel wrote:
> Well, looks like I may have misinterpreted your question. I assumed
> that after a "strip", the interest is more on what's left rather than on
> what's removed ;-). In any case, even with my interpretation, a simple
> Dir([YourField]) would have sufficed. Oh well...
>

Reply With Quote
  #8 (permalink)  
Old 28-Jul-2006, 08:16 AM
RoyVidar's Avatar RoyVidar
Guest
 
Posts: n/a
   
   
Re: STrip path of a file

  Donate Today!  
SF wrote in message :
> Hi,
>
> I have file eg G:\MYPICTURES\123456.JPG
>
> What is the function to strip the PATH (eg G:\MYPICTURES\) out of the
> enture string?
>
> SF


For the fun of it, having a bit of flexibility:

Dim strDrive As String
Dim strDir As String
Dim strFile As String
Dim strExt As String

Const cstrFullName As String = _
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10777
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10777
"G:\MYPICTURES\123456.JPG"

With WizHook
.Key = 51488399
.SplitPath cstrFullName, strDrive, strDir, strFile, strExt
Debug.Print strDrive, strDir, strFile, strExt
End With

--
Roy-Vidar


Reply With Quote
   Click Here to Donate Now!

Support Us!
Become a Promoter!
Gurfateh ji, you can become a SPN Promoter by Donating as little as $10 each month. With limited resources & high operational costs, your donations make it possible for us to deliver a quality website and spread the teachings of the Sri Guru Granth Sahib Ji, to serve & uplift humanity. Every contribution counts. Donate Generously. Gurfateh!
ReplyPost New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!

Bookmarks


(View-All Members who have read this thread : 0
There are no names to display.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Tools Search
Search:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

» Active Discussions
How does Sikhi help you...
Today 18:56 PM
27 Replies, 922 Views
Keeping Amrit Vela
Today 16:49 PM
12 Replies, 907 Views
Do you believe in...
Today 15:08 PM
196 Replies, 4,083 Views
Occultism - Rejection in...
Today 14:04 PM
59 Replies, 2,587 Views
Panjabi
By Ishna
Today 13:43 PM
14 Replies, 287 Views
Black Sikhs?
Today 06:33 AM
20 Replies, 5,816 Views
Man Driving Without...
Today 05:06 AM
5 Replies, 139 Views
Request for assistance...
Today 04:24 AM
8 Replies, 90 Views
Losing My Religion: Why...
Today 03:03 AM
13 Replies, 350 Views
Health Exercise And...
Today 02:10 AM
1 Replies, 93 Views
Sikh Spokesman (ਪੰਜਾਬੀ...
Today 02:10 AM
176 Replies, 4,513 Views
How Religions Change...
Today 02:07 AM
1 Replies, 108 Views
Rozana Reports (ਪੰਜਾਬੀ...
Today 01:52 AM
313 Replies, 7,603 Views
Parkash Guru Amar Das ji...
Yesterday 17:07 PM
3 Replies, 87 Views
Serious challenges to...
Yesterday 16:49 PM
0 Replies, 160 Views
» Books You Should Read...
Powered by vBadvanced CMPS v3.2.3
All times are GMT +6.5. The time now is 19:53 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2 Copyright © 2004-12, All Rights Reserved. Sikh Philosophy Network


Page generated in 0.53428 seconds with 32 queries
0