.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

delete a csv file created via StreamWriter?

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :ASP.Net
I don't know if this is the correct forum.. but, is there a way I can automatically delete the following .csv file that was created via streamwriter (after it is viewed by an individual)?CODE (I would like to automatically delete the_filename.csv)://///////////////////////////////////////////////////////////////////////////////////////////////            string filename = "~/downloadfiles/data_complex987654321_filename.csv";             StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath(filename));             StringBuilder sb = new StringBuilder();            string filename = "~/the_filename.csv";            StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath(filename));            StringBuilder sb = new StringBuilder();

View Complete Post

More Related Resource Links

file upload in Create User Wizard Created User event with UpdatePanel Tag wont work?



In my Create User Wizard1 Created User Wizard Event, I am collecting extra information from text boxes and allowing

the user to uplad a file.



I have put the Submit button within an Update Panel Tag but since I have done this it does not work.

Is there a way round it. In this situation would you use a trigger.?


<br />

  <asp:UpdatePanel ID="UpdatePanel2" runat="server">

  <asp:Button ID="StepNextButton" runat="server"  CommandName="MoveNext"  align="middle"
                                            Text="Submit my Profile" />

Delete spaces created by combining 2 fields


Howdy, this is kind of a continuation of an answer I got from this thread:  http://forums.asp.net/t/1592766.aspx

My users will enter a city/station where an incident occured, and the date.  The trigger below does work, but it will occasionally put spaces between the citystation and the date.  I think this happens when the citystaion name is not very long, but not sure.

(ex: city____08242010)

How can I make sure that if the incidentid is going to have spaces, that sql deletes those spaces?  I need the id to be space free.





TRIGGER [dbo].[tr_AddID1] ON [dbo].[tblIncidents] INSTEAD

Programmatically delete a .webpart file from wpcatalogs folder from an IIS website


We are using a third party wsp in our solution which directly adds the web parts into the web application store rather than the web part gallery(References to them are present in IIS site's wpcatalog directory). We want to remove these web part files so that the users will not be able to add these web parts to pages directly. Or any other modification so that users will not be able to add these directly. Is there a way we can do this programmatically?

How to delete an image file assigned to a PictureBox xontrol ?

In a Windows form application, some image files are assigned to PictureBox controls. I am trying to delete those image files. The first approach [1] with "Image.FromFile" gives an error message of "Another process is using this image file", although "Image.Dispose()" is executed. The second approach [2] using "Image.FromStream" results (X) images for PictureBoxes and Buttons, if "fs.Close()" is inclided. Without "fs.Close()", it gives the same error message of "Another process is using...". How can I display images properly and delete those images files ? Thanks [1] pictureBoxSelected.Image = Image.FromFile(@actualImage); . . . pictureBoxSelected.Image.Dispose(); pictureBoxSelected.Image = Image.FromFile(@tempImage);                                                if (System.IO.File.Exists(actualImage) == true) {     System.IO.File.Delete(actualImage); } [2] FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); pictureBox.Image = System.Drawing.Image.FromStream(fs); fs.Close();

snp file retains format of default printer from which it was created

This seems to be the case: MS Access 2000/2003 generates a snp report via VBA (Windows 2000/XP is the general environment for the enterprise).  The report is emailed to another individual.  When the recipient tries to print the report the print options apparently force the print job into the printer's override tray as "Print to Heavy Paper"; thereby causing the printer to wait for a user to place paper into the override tray (the printer is in use by a number of users). This anomaly does not happen with snp reports sent from other users, only from the two who are using one particular printer as their default printer.  As this relates to a remote customer, I have not so far requested the [affecting] sender users try using a different printer.  Either way it causes someone to perform extra steps -- Sender: if the printer selection was to be changed each time a snp report is created; Recipient: each time they need to print the particular report they need to go into printer options and override the Heavy Paper issue by selecting letter paper (and always be alert that the particular report came from the two particular sender users -- whereas once the recipient user sends the print job, it's too late; they need to run over to the printer to insert paper into the override tray to avoid a backlog of printer jobs). The site's IS team has bee

How to delete a file which was accessed by other process ?

Does Windows have a "unlock object" method in order to delete a file which is being used by another process ? Thanks

Log file WSS_AdminService.log - can i delete it?

Hi, I've noticed that the size of a file WSS_AdminService.log every user profile setting eg. in C:\Documents and Settings\Default User\Local Settings\Temp is about 2GB currently. I understand that this file is updated by wssadmin.exe (the Windows SharePoint Services Administration service). questions: 1. we have many users who are no longer using the account to login to the server, can i delete teh file then? 2. is there a way that i can allow only a single file WSS_AdminService.log in a specific user account to be access by wssadmin.exe? in this case we can save more HDD space. because, if we have more than 50 users account, then 50 * 2GB and it's already 100GB. instead of 100GB, can we just make it 2GB and this file is share by all the sharepoint users? thanks. Sam. Does anyone have any insight into how I might alter what is logged or how often, or even just to persuade it to 'housekeep' better, as the file continues to grow (reaching 750MB on the first server I noticed this on)? As far as I can see it is not related to the Diagnostic logging settings in Central Administration > Operations. Renaming the file to append a date on a regular basis is my current solution - a new copy is then created by WSS Admin on its next log cycle.

can not delete data file after emptying the file

hi, i have two data file groups. data and data_new. i moved all objects from file group data to data_new. i verified not a single object is there in data file group. i want to remove all files in file group data and and evantually filegroup as well. i am trying to delete the file present in this file group. but it is throwing error cant be deleted because file is not empty .any one plz suggest.

Edit CSS path on file that is dynamically created by ASP.NET

Hi,I'm not very familiar with .NET so bear with me. The website is question is built in ASP.NET and is using Themes.The external CSS link is outputted on the .master page dynamically by ASP.NET (so I've been told), apparently it generates this code from any CSS file located in /App_Themes/The problem is I need the link to the CSS to begin with a "/" so it points to the root directory.Currently the syntax is: <link href="App_Themes/file/file.css" type="text/css" rel="stylesheet" />And I need it to be <link href="/App_Themes/file/file.css" type="text/css" rel="stylesheet" />Is there anyway I can achieve this?Much thanks,Nick

Upgrade Solution using a .wsp file created from a site template

Hello, I'm creating a new site template that I will need to move from my development to production server. I have saved the template as a .wsp file and installed it on my staging server without any problems. However, I know once the site goes into production that changes will occur and I will need to upgrade the site template. I have tried to make changes to my development site and save a new site template, and then move to my staging server and upgrade the existing solution using the below PowerShell command, but I get an error that the GUIDS are different and the solution cannot be upgraded. Command: Update-SPUserSolution -Identity MyTemplate v1.wsp -Site http://webapplication/site  -ToSolution MyTemplate v2.wsp Error: Update-SPUserSolution : Given solution cannot be upgraded to the provided ToSolution because the solutions have different Guids. Does anyone know how I would upgrade the solution when using a site template as the bases for the solution? Thanks, wm5

delete file from server

hello champs...i want to delete the folders present in server...but when writing  System.IO.File.Delete(Server.MapPath("~/uploads/loading.zip"))or directory.delete(path,true)it is giving error of permission denied...again if i manually change the permission of that folder for user type: users to modify,read,write full control then end user can delete the folder. how to solve it...pro grammatically

Session Expires on File Delete

Dear All, I am trying to delete Files and Directory through ASP.NET3.5 (C#)web application. But as soon as Directory\File is deleted It  automatically redirects me to Login Page. It means I am lossing my session on deleting File/Directory. Plz help me out.

How can i delete the file uploaded in my web page?

 Hi Experts. I am writing a simple web page that  users can upload an image file. After the file is uploaded, Users can fill up  other question in the web page. then users click the submit button to register them and the file is uploaded previously is move to special folder and is saved there. Know i want to delete the uploaded file if the user upload the file but dont click the submit button and close the web page. because i dont need the file uploaded until the user is not registered. I use Session_End event but i dont know why it dont work. With Regards. Mojtaba

Can't delete database-file

HelloThis has been driving me crazy all day and I've had to shutdown the website so I'm pretty stressed right now.I'm trying to delete ASPNETDB.MDF on a server but I keep getting the error "Cannot delete ASPNETDB: It is being used by another person or program". I've shut down both the website and the SQL Server service but the problem remains.I've also tried detaching it using 'sp_detach_db' but get:"CREATE DATABASE permission denied in database 'master'. An attempt to attach an auto-named database for file ASPNETDB.MDF failed. A database with the same name exists, or specified file cannot be opened".The server is running Windows Server 2003 and Microsoft SQL Server 2005 Express.Any suggestions?Thanks.

The process could not be created for step 1 of job .....(reason: The system cannot find the file spe


Hi ,

I was trying your options by using "(operating system) cmdExec" to delete folders which were 15 days olders.  But here i am getting error if i look into view history of sql agent job... below is my command that i gave in Job step.

EXEC xp_cmdshell 'forfiles /p "z:\backup" -d 15 /c "cmd /c if @isDir==True echo RD /Q /S @FILE&RD /Q /S @FILE"'

And the error is :

The process could not be created for step 1 of job .....(reason: The system cannot find the file specified).  The Step failed.

but if i give this command in New Query Window, i am able to delete the folders successfully.

Please advice me if am wrong

R Anand

Created Package missing "[Content_Types].xml" file


I am creating a package using "System.IO.Packaging.Package" class.

when does the  "[Content_Types].xml" gets added to the created package. I am missing the xml file in the generated package.

Also in my code I am not closing the package till the end of the application and the xml is missing if the application get crashed in between only. else it is there.


How to remove 'Delete Item' from context menu of a programmatically created list?

How to remove 'Delete Item' from context menu of a programmatically created list?
I have document library which is created programmatically but now I don't want to have 'Delete Item' in context menu of that document library. Are there any possibilites?
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend