473,498 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

file system object

Hi

I am building an upload script that overwrites any file with the same name,
however the file could be a jpg, gif, bmp etc

Using 'fso.FileExists ' i can find if a file of the same name exists and
remove it. The file will be saved as strMemberId.strFileExt

There is a possibility that file xyz.jpg may be re-uploaded as xyz.gif thus
while the new image will be written to the folder the previous file will not
be removed.

I am trying to find the best way of finding the file name of a file without
the extension so I can delete any files that may exist with the same name
but a have different extension. Is there a way of calling a wildcard in asp?
eg ' fso.FileExists(Server.MapPath("../tempfolder/" & strMemberId &".*" ))
' - tried this & several other combinations but it does not work.

The only other way I can see of doing it is to pass the file name into a
string, strip the extension off it and then build an array to loop through
the possible extensions but I am sure there is a better way.

Any thoughts?

Thanks In advance

J
Jul 19 '05 #1
1 1652
*usura* wrote:
Hi

I am building an upload script that overwrites any file with the same
name, however the file could be a jpg, gif, bmp etc

Using 'fso.FileExists ' i can find if a file of the same name exists
and remove it. The file will be saved as strMemberId.strFileExt

There is a possibility that file xyz.jpg may be re-uploaded as
xyz.gif thus while the new image will be written to the folder the
previous file will not be removed.

I am trying to find the best way of finding the file name of a file
without the extension so I can delete any files that may exist with
the same name but a have different extension. Is there a way of
calling a wildcard in asp?
eg ' fso.FileExists(Server.MapPath("../tempfolder/" & strMemberId
&".*" )) ' - tried this & several other combinations but it does not
work.

The only other way I can see of doing it is to pass the file name
into a string, strip the extension off it and then build an array to
loop through the possible extensions but I am sure there is a better
way.

Any thoughts?


In the JScript docs, the DeleteFile method supports wildcards.
Alternatively instantiate a folder object and enumerate the files
collection within it checking the name of each item with a compiled
regexp containing your filename 'mask'.
--
Andrew Urquhart
- FAQ: http://www.aspfaq.com
- Archive: http://tinyurl.com/38kzx (Google Groups)
- Contact me: http://andrewu.co.uk/contact/
- This post is probably time-stamped +1 hour - blame my ISP (NTL)
Jul 19 '05 #2

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

Similar topics

9
715
by: Paul | last post by:
Hi, VB.NET is saying the file I am creating is in use by another process and won't complete its task of moving the file to the specified destination folder. Here is my code (the main bit...
11
3051
by: Skc | last post by:
I have a .txt which has been exported as a .csv from an external source. What i need to do is to import this into SQL2000 (into a table) but I need to do special things on the data: 1. I need to...
2
2296
by: aallee83 | last post by:
i'm new in asp.net after develop my solution i copied it on the server where I want it to run but something cares... WHAT?!?! thank you in advance File or assembly name System, or one of its...
0
2533
by: troutbum | last post by:
I am experiencing problems when one user has a document open through a share pointing to the web site. I use the dsolefile to read the contents of a particular directory and then display them in a...
1
1694
by: apple | last post by:
i try to print image file in a directory using PrintDocument. It will raise printPage event to draw image to the printer. The file will be deleted after print and the directory will be checked...
1
5682
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out...
3
3956
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user...
2
2317
by: arun1985 | last post by:
In the project i am using i am having the following code and when i upload it to the server.Its givig me the following error in the global.cs file. Server Error in '/' Application. ...
19
5350
by: Lee Crabtree | last post by:
Is there a class in the framework that allows me read text from a file in an unbuffered manner? That is, I'd like to be able to read lines in the same manner as StreamReader.ReadLine(), but I also...
4
2107
by: MikeJ | last post by:
make a While loop ofs = TextFileServer("somefile") string srow while (ofs=false) { srow=ofs.getRow(); Console.Writeline(srow); }
0
7125
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,...
0
7004
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...
0
7208
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...
1
6890
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...
0
5464
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3095
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...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1423
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
292
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.