Changing file name

B

Bonzol

Vb.net 2003, Web application
Hey all!

Just a quick question.

I have a site which allows users the ability to upload files by the
HTML brows button control.

My question is if a user submits a file,, and every file they submit I
want my code to change the name of it.. So say the user submits
'Hello.txt'. When they press submit I want it to be changed to
'Hello1.txt'. I tried just changing the name but it stopped the file
from working. Or also. what commands does one use to just change the
name of a selected file on the local machine?

Any help would be greatly appreciated.

Thanx in Advance
Chris
 
C

Cor Ligthert [MVP]

Bonzol,

For the file upload it is very important what method you use on the Server
side.
There is no standard method for that.

(Asp)Net has as least 2 classes for that, using those you can sure after the
upload change the dataname or the file path (or Database) were you want to
store it.

Therefore show the serverpart so we see how you handle the input/file

Cor
 
B

Bruce W. Darby

Chris,

While I don't really have the programming skills necessary to actually whip
out the code quickly, in pseudo-code the logic would run something like the
following...

If user uploads file then
get the filename of the file
check the data storage and get the total number of files uploaded by the
user
assign the upper bound of the data storage to a variable
increment the variable by one
split the filename at the "." into two temp variables
concatenate the storage variable onto the end of temp1 variable and
then...
concatenate temp2 back onto the end of temp1 and assign that name to the
file.

VB.Net has many methods that I've been learning about recently that can do
wonderful things and my little example may be a bit too verbose... or not
verbose enough. :) I've actually been 'reading' through the help and
checking out the methods and properties of methods along with the help I've
been getting. Hope this helps you in some small way.
 
N

Newbie Coder

Not a solution again though Cor


Cor Ligthert said:
Bonzol,

For the file upload it is very important what method you use on the Server
side.
There is no standard method for that.

(Asp)Net has as least 2 classes for that, using those you can sure after the
upload change the dataname or the file path (or Database) were you want to
store it.

Therefore show the serverpart so we see how you handle the input/file

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top