473,396 Members | 2,076 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,396 software developers and data experts.

deleting *.doc in asp.net

I want to delete all my .doc files in a specific directory.

I tried to do this using the File.Delete method, but it doesn't allow
"*.doc" paths.

So I tried the following code:

Dim objFSO = Server.CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile(Server.MapPath("*.doc"))

and it works on my local pc, but I doubt I should be using classic asp
components with asp.net.. what was is the equivalent function in
asp.net?

Cheers.
--

fiddlewidawiddum
Nov 20 '05 #1
4 1258
off the top of my head try something like this :

DirectoryInfo dir = new DirectoryInfo(@"c:\tmp");
FileInfo[] docfiles = dir.GetFiles("*.doc");

Foreach( FileInfo f in docfiles)
{
File.Delete( f.Name)
}

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Stimp" <re*@spumco.com> wrote in message
news:sl****************@carbon.redbrick.dcu.ie...
I want to delete all my .doc files in a specific directory.

I tried to do this using the File.Delete method, but it doesn't allow
"*.doc" paths.

So I tried the following code:

Dim objFSO = Server.CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile(Server.MapPath("*.doc"))

and it works on my local pc, but I doubt I should be using classic asp
components with asp.net.. what was is the equivalent function in
asp.net?

Cheers.
--

fiddlewidawiddum

Nov 20 '05 #2
On Sun, 20 Nov 2005 John Timney ( MVP ) <ti*****@despammed.com> wrote:
off the top of my head try something like this :

DirectoryInfo dir = new DirectoryInfo(@"c:\tmp");
FileInfo[] docfiles = dir.GetFiles("*.doc");

Foreach( FileInfo f in docfiles)
{
File.Delete( f.Name)
}


nope doesn't seem to work.

Dim dir As DirectoryInfo = New
DirectoryInfo(Server.MapPath("mydirectory"))

Dim docfiles() As FileInfo = dir.GetFiles("*.doc")

Dim f As FileInfo

For Each f In docfiles
File.Delete(f.Name)
Next

--

fiddlewidawiddum
Nov 20 '05 #3
On Sun, 20 Nov 2005 John Timney ( MVP ) <ti*****@despammed.com> wrote:
off the top of my head try something like this :

DirectoryInfo dir = new DirectoryInfo(@"c:\tmp");
FileInfo[] docfiles = dir.GetFiles("*.doc");

Foreach( FileInfo f in docfiles)
{
File.Delete( f.Name)
}


actually I just got it working... the problem was with the path used in
the File.Delete section

Thanks!
--

fiddlewidawiddum
Nov 20 '05 #4
Sorry - as I said off the top of my head. Glad to have helped.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Stimp" <re*@spumco.com> wrote in message
news:sl****************@carbon.redbrick.dcu.ie...
On Sun, 20 Nov 2005 John Timney ( MVP ) <ti*****@despammed.com> wrote:
off the top of my head try something like this :

DirectoryInfo dir = new DirectoryInfo(@"c:\tmp");
FileInfo[] docfiles = dir.GetFiles("*.doc");

Foreach( FileInfo f in docfiles)
{
File.Delete( f.Name)
}


actually I just got it working... the problem was with the path used in
the File.Delete section

Thanks!
--

fiddlewidawiddum

Nov 20 '05 #5

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

Similar topics

5
by: flupke | last post by:
Hi, i'm having trouble with deleting elements from a list in a for loop ============== test program ============== el = print "**** Start ****" print "List = %s " % el index = 0 for line...
15
by: Rick | last post by:
Hi, Does deleting an object more than one times incur undefined behavior? I think it doesn't but just making sure... thanks Rick
6
by: Abhijeet | last post by:
I was just toying around idea of deleting this from a member function. Was expecting that any acess to member variable or function after deleting sould give me dump(segmetation violation).Cause now...
6
by: Matan Nassau | last post by:
Hello. i have a composite which i want to delete. this is a composite which represents a boolean expression (see a previous post of mine with more details at...
3
by: Nathan Bloom | last post by:
Hi, I have a data entry form (access 2000) that also allows the user to add, update, and delete records from the form. The Delete action is carried out in an event procedure and has the...
5
by: Mojtaba Faridzad | last post by:
Hi, with SetDataBinding( ) a DataGrid shows a DataView. user can select some rows in the grid by holding cotrol key. when user clicks on Delete button, I should delete all selected rows. I am...
4
by: al havrilla | last post by:
hi all what does the phrase: "scalar deleting destructor" mean? i'm getting this in a debug error message using c++ 7.1 thanks Al
6
by: Martin Bischoff | last post by:
Hi, I'm creating temporary directories in my web app (e.g. ~/data/temp/temp123) to allow users to upload files. When I later delete these directories (from the code behind), the application...
3
by: Kimera.Kimera | last post by:
I'm trying to write a program in VB.net 2003 that basically deletes all files, folders, sub-folders and sub-sub folders (etc). The program is simply for deleting the Windows/Temp folder contents,...
2
Parul Bagadia
by: Parul Bagadia | last post by:
I have written a code for deleting certain value from linklist; it's not working; where as i have written one for deleting a no., after given no. which works fine! I even debugged it; but invain;...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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,...
0
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...
0
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...
0
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,...

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.