Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
filesystem object quick query
Old 02-28-2007, 07:51 PM filesystem object quick query
tonya's Avatar
Ultra Talker

Posts: 485
Location: world traveller based in UK
Trades: 0
Hi there.
I am using the filesystem object to obtain a list of directories and files within a directory.

Each example shows me how to produce a complete list using a For Each statement eg:

For each file in myFolder.files........
some code ......
Next

What if I want it to just give me the first item in the list?

I tried a Do while and counting the filesystem object but came unstuck.

Any help appreciated - I clearly am crap at my basic VBscripting loops ands tatements but its been so long since I actually learnt the **** stuff and these days I reuse so much of the code I wrote eons ago.

Thanks
__________________
Tonya

::
Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE
tonya is offline
Reply With Quote
View Public Profile Visit tonya's homepage!
 
 
Register now for full access!
Old 02-28-2007, 08:11 PM Re: filesystem object quick query
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
x = myFolder.files(0)

or, to error proof it

if myFolder.files.count > 0 then x = myFolder.files(0)
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 03-01-2007, 10:34 AM Re: filesystem object quick query
tonya's Avatar
Ultra Talker

Posts: 485
Location: world traveller based in UK
Trades: 0
Can you give me a quick example of what the command statement would look like please

eg:

Do while x = >0
Response.write MyFolder.Name
Loop

????????? sorry my brain is compeltely dumbed / numbed out this morning.
__________________
Tonya

::
Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE
tonya is offline
Reply With Quote
View Public Profile Visit tonya's homepage!
 
Old 03-01-2007, 11:06 AM Re: filesystem object quick query
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
He just did. It's the second code line he typed.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 03-01-2007, 12:40 PM Re: filesystem object quick query
tonya's Avatar
Ultra Talker

Posts: 485
Location: world traveller based in UK
Trades: 0
Ok so here i am being really dumb

if myFolder.files.count > 0 then x = myFolder.files(0)
Response.write [some code]
End if

???? no that just does not seem right ?
Shouldn't I be doing something like setting i to an integer less than the file number count and asking a loop to find that number then execute my scrip (write the filename) EG in my case set i = 0 or 1 and use a for each which ends after it finds the correct value of i.

Ok so I am in a fix. What I really need is someone to give me an example of the lines I require to pull either a random item or the first item in a list of files from the filesystem object.

p.s its for a gallery I am building and next to the folder name I want a thumbnail but clearly only need one thumbnail. I can get it to list the whole lot using my For each statement but cant work out how to just get it to give me 1.

Perhaps I am at fault for not clearly asking for help to write the whole conditional statement not just the wee bit that gives me x - sorry adam but smart answers don't help either when I am clearly not feeling smart enough having spent an entire evening (9pm to 1am) working on this and still feeling dumb.

During my daylight hrs I work as a property manager and look after my 12 month old son - my coding is done at night when my brain is already exhausted and when you have been re-reading the same code and the same chapter in the very old dog eared asp book I had when I first learnt the stuff 6 years ago for 4 hrs solid and still none the wiser you aks for help.

Please please someone point me in the direction of a nice 'clear and simple' example ....... or help me to construct the whole statement.

Thanks hopefully not sounding toooo frustratingly fed up with this !!
__________________
Tonya

::
Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE
tonya is offline
Reply With Quote
View Public Profile Visit tonya's homepage!
 
Old 03-01-2007, 02:51 PM Re: filesystem object quick query
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Nobody will be able to write your code for you unless you want to give somebody full access to your server. Otherwise the best any of us can do is point you in the right direction.

If you only want to access one file, you don't need ( or want ) a for loop. You don't need a do loop, either. The whole point of a loop is you want to do something an unknown number of times. You want to do something once. So no loop.

Again, the code you need is:

If myFolder.Files.Count > 0 Then x = myFolder.Files(0)


Where x is a local string variable. Then you do something with x. We don't know what, because we can't see the rest of your code. You might want to response.write it, you might want to form an img or a tag around it, you might want to send it to a control.

There's no end if because this doesn't span multiple lines.
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 03-07-2007, 11:09 AM Re: filesystem object quick query
tonya's Avatar
Ultra Talker

Posts: 485
Location: world traveller based in UK
Trades: 0
Oh ok that explains it. I was getting really fed up and ultra frustrated with the whole project at that point. sorry for sounding petulant. I only wanted an example hence did not put whole code up for webmaster talk users to see.

Thanks and once again sorry for being completely daft and not realising that I was looking at the solution anyway.

You explained it really well the second time around and thanks !!!
__________________
Tonya

::
Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE
tonya is offline
Reply With Quote
View Public Profile Visit tonya's homepage!
 
Old 03-07-2007, 02:40 PM Re: filesystem object quick query
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Quote:
Originally Posted by tonya View Post
Thanks and once again sorry for being completely daft and not realising that I was looking at the solution anyway.
No worries. You should see my boss ( King Kong ) when he wants something. Glad it works for you.
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to filesystem object quick query
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.96798 seconds with 12 queries