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

Why doesnt this work?

I am trying to add allowed file extensions to an arraylist, as follows. I
really want it so that the values of files will be a comma serparted string
that i set in the property window. This is an upload server control and i
then check the _Allowedfiles arraylist to see if it has the extension and
then upload or not. Right now only the first extnesion gets added - in this
case .jpg, while.gif isnt added. What am i doung wrong?

Thanks...
Ashok
Dim files As String = ".jpg, .gif "

Dim fileArray() As String = files.Split(",")

Dim k As String

For Each k In fileArray

_AllowedFiles.Add(fileArray(i))

Next
Nov 18 '05 #1
2 919
Showjumper wrote:
I am trying to add allowed file extensions to an arraylist, as follows. I
really want it so that the values of files will be a comma serparted string
that i set in the property window. This is an upload server control and i
then check the _Allowedfiles arraylist to see if it has the extension and
then upload or not. Right now only the first extnesion gets added - in this
case .jpg, while.gif isnt added. What am i doung wrong?

Thanks...
Ashok
Dim files As String = ".jpg, .gif "

Dim fileArray() As String = files.Split(",")

Dim k As String

For Each k In fileArray

_AllowedFiles.Add(fileArray(i))

Next


You're iterating through fileArray using "For Each" but then you call
_Allowedfiles.Add() using an index that has nothing to do with the loop.

change:

_AllowedFiles.Add(fileArray(i))

To:

_AllowedFiles.Add( k.Trim())

Note that I added a call to Trim() becuase the Split() will leave the
file extentions having leading and/or trailing space characters.

--
mikeb
Nov 18 '05 #2
Thanks Mike. That was it.
"mikeb" <ma************@mailnull.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Showjumper wrote:
I am trying to add allowed file extensions to an arraylist, as follows. I really want it so that the values of files will be a comma serparted string that i set in the property window. This is an upload server control and i then check the _Allowedfiles arraylist to see if it has the extension and then upload or not. Right now only the first extnesion gets added - in this case .jpg, while.gif isnt added. What am i doung wrong?

Thanks...
Ashok
Dim files As String = ".jpg, .gif "

Dim fileArray() As String = files.Split(",")

Dim k As String

For Each k In fileArray

_AllowedFiles.Add(fileArray(i))

Next


You're iterating through fileArray using "For Each" but then you call
_Allowedfiles.Add() using an index that has nothing to do with the loop.

change:

_AllowedFiles.Add(fileArray(i))

To:

_AllowedFiles.Add( k.Trim())

Note that I added a call to Trim() becuase the Split() will leave the
file extentions having leading and/or trailing space characters.

--
mikeb

Nov 18 '05 #3

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

Similar topics

4
by: Developwebsites | last post by:
#ifndef PERSON_H #define PERSON_H #include<iostream> #include<iomanip> #include<string> class Person { protected: char name;
1
by: Station Media | last post by:
Hi, here my problem, i use stored procedure in ACCESS database(latest version), and i would like to use this procedure but it doesnt work, do you know why ? Procedure: PARAMETERS MyField Text...
3
by: Clouds | last post by:
Hi ! How do I add the dynamic event handler for a dropdownlist present in the itemtemplate of a datalist !! I am doing it in the itemdatabound event of the datalist but it doesnt work... I am...
8
by: pmud | last post by:
Hi, I am using a compare validator in asp.net application(c# code). This Custom validator is used for comparing a value enterd by the user against the primary key in the SQL database. IF the...
3
by: Bruno Paquette | last post by:
I have installed visual studio .net and now i started to write the first few examples from the 70-315 book by Kalani. It looks like all server side code that i put between <% %> doesnt process...
0
by: Juna | last post by:
I have been working in vs2003, but now started to work in vs2005 but the problem, I have simple web application not website, which work i mean open in browser when we press F5 or run the...
1
Digital Don
by: Digital Don | last post by:
I am writing a program for Peg solitaire... To check for no repetition of previous states I use a Set for storage of Board states.. The pronblem is when I declare the set as type char i.e. set...
3
by: jx2 | last post by:
hi guys i would appriciate your coments on this code - when i ran it for the very first time it doesnt see @last = LAST_INSERT_ID() but when i ran it next time it read it properly i need to know it...
1
by: Dany13 | last post by:
hi all. i using some text box for input value and some localvarible for passing this data to dataset . give instance for correct row of dataset and data in data table . use one gird view for...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.