473,799 Members | 3,093 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

All i want is the first file

When doing a getfolder() I want the first file in the resulting FILES
collection. I don't want to do a for/next cuz the list may be very long.
Just the first file is all. How do I do this? Doin a

Set objFile=Folder. Files(1) generates a Invalid procedure call or agument
error.

Can anyone help?

Thanks!
Jul 19 '05 #1
2 1749
problem may be that the "first" isn't really defined.
Anyway, do a simple loop till i = 1
--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Jon Glazer" <jg************ ***@adconn.com> wrote in message
news:IW******** *************@f e2.columbus.rr. com...
When doing a getfolder() I want the first file in the resulting FILES
collection. I don't want to do a for/next cuz the list may be very long.
Just the first file is all. How do I do this? Doin a

Set objFile=Folder. Files(1) generates a Invalid procedure call or agument
error.

Can anyone help?

Thanks!

Jul 19 '05 #2
"Jon Glazer" wrote in message
news:IW******** *************@f e2.columbus.rr. com...
: When doing a getfolder() I want the first file in the resulting FILES
: collection. I don't want to do a for/next cuz the list may be very long.
: Just the first file is all. How do I do this? Doin a
:
: Set objFile=Folder. Files(1) generates a Invalid procedure call or agument
: error.

Hi Jon...

This is what I came up with. It allows you to return the filename based on
an index value.

<%@ Language=VBScri pt %>
<%
Option Explicit
Response.Buffer = True

Function ShowFolderList( folderspec, index)
Dim fso, folder, file, s, i, d
i = 0
Set fso = CreateObject("S cripting.FileSy stemObject")
Set folder = fso.GetFolder(f olderspec)
Set d = CreateObject("S cripting.Dictio nary")
for each file in folder.Files
i = i + 1
s = file.name
d.Add i, s
Next
ShowFolderList = d.Item(index)
set fso = nothing
set folder = nothing
set d = nothing
End Function

Response.Write( ShowFolderList( "c:\inetpub\e", 1))
%>

If you just want it to always return the first one, you can shorten it to
this:

<%@ Language=VBScri pt %>
<%
Option Explicit
Response.Buffer = True

Function ShowFolderList( folderspec, index)
Dim fso, folder, file, s
Set fso = CreateObject("S cripting.FileSy stemObject")
Set folder = fso.GetFolder(f olderspec)
for each file in folder.Files
s = file.name
exit for
Next
ShowFolderList = s
set fso = nothing
set folder = nothing
End Function

Response.Write( ShowFolderList( "c:\inetpub\e") )
%>

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 19 '05 #3

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

Similar topics

3
3007
by: Chris Cioffi | last post by:
I started writing this list because I wanted to have definite points to base a comparison on and as the starting point of writing something myself. After looking around, I think it would be a waste of time to start writing yet another IDE and so am now thinking in terms of new features/plug-ins for existing systems. Right now I mostly use Komodo Personal and it's pretty close to being what I want. They don't currently support plug-ins,...
2
12844
by: SL_McManus | last post by:
Hi All; I am fairly new to Perl. I have a file with close to 3000 lines that I would like to split out in a certain way. I would like to put the record type starting in column 1 for 2 spaces, the employer code in column 23 for 29 spaces and employer description in column 53 for 30 spaces. I have tried modifying an existing file with no real success. I haven't found anything that specifically answers my question. Any guidance would be...
11
2140
by: Michael B. | last post by:
I'm still learning C so I've written a simple app which lets you make a contact list (stored as a linked list of structs), write it to a file, and read it back. It works fine, but I notice in my loading procedure there's a point or two where I'll malloc a struct which I then don't need, and dispose of it; I was wondering if there was some way I could optimize this kludge out of existence: void loadContacts () { int fd, bytesread; if (...
4
2058
by: veereshai | last post by:
i want to copy the functions from my source file into a new file...and convert each function into a new object file by compiling it. now, i want to invoke the function using the object file i have created and not by invoking the original function(i.e delete the part which has the function and then try to invoke the same function by including the object file into my source code). Is this possible?
2
1481
by: Bassem | last post by:
Hi Everyone. Thanks for Help. Simply I want to create a file saved in it information but in the same time when anyone try to read this information couldn't understand the contents of the file. As an example: this is a contents of a file like the one I want. "]eŒ:  B$m{ڑG ً ے ے ZG
1
2505
by: johnnyh | last post by:
I am currently using ASP.Net / C# to partially upload the first 100K of a CSV file to programattically extract the header information for field mapping against our database and for a test sample of records to check some validation before entire file is uploaded. (Files can be HUGE) Question - what about when the file is Zipped? Can I still upload the first 100K of the file and somehow unzip that portion of the file? Or
7
1321
by: Edward Yang | last post by:
In my test, I have two web applications app1 and app2, and I configure them as follows in IIS: $/comboapps |--web.config |--bin | app1.dll | app2.dll |--app1 | form1.aspx
3
1517
by: jhanzl | last post by:
All - I am looking into a way of uploading just the first portion of a large (> 100M) .csv (text) file to the server. Ultimately what I want to do is read the first line of the .csv file, which has the column headers for the file for field mapping to a server-side database WITHOUT actually having to upload the entire file to the server. The files are simply too large to have to wait for the upload to complete before proceeding to the...
3
419
by: cs | last post by:
Hi, I'm new to C and would appreciate any feedback on the following program, asplit, which splits a file into 2 new files, putting a certain number of lines in the first file, and all the rest in the second file. Any comments as to non-portability, stylistic infelicities, outright bugs or anything else would be very much appreciated.
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9538
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10473
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10249
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10219
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10025
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7563
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5461
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.