Web Forms :: How To Delete A File From Disk
Apr 5, 2010I want to delete an image from disk
how do I do this?
I want to delete an image from disk
how do I do this?
This is my House_p table
Iamge3 Image2 Image1 Name ID
3.JPG 2.JPG 1.JPG SARA 1
I have two tables:
Table1
IDTable1
CustomerName
Table2
IDTable2
IDTable1
FIlePath
There is a one to many relationship with key field = IDTable1
I have created one client and uploaded 20 files
Now I would like to:
Delete the client record from Table1
Delete all associated records in Table2
Delete all files from the disk based on the paths in Table2
I am able to delete all the records in both tables but I cannot delete the disk files. Here is what I ahve so far:
[Code]....
I m trying to read the tags of a local HTML file. I found out this code online but it works for the aspx pages on the server and of the current app only.
___________________________________________________
using System.Web.UI.HtmlControls;
foreach (Control c in this.Page.Header.Controls)
{
if (c.GetType() == typeof(HtmlMeta))[code]...
THis code acceses the following section of an html page -
<meta name="Keywords"content=" B=Msdn;A=Forums;L=en-US;"
/>
My question is how can i do the same for a local(client) html page?
Can i do it for a html page on server?
My website provides a facility to upload images, using the ASP.NET FileUpload control. We accept both jpeg and tiff formats but I have just decided that all tiffs should be converted to jpegs at the time of upload. If possible, I want to avoid saving the original tiff to disk. I would any sample coding for achieving this conversion prior to saving (ideally in VB.NET, though I could always run C# code through a converter).
View 4 RepliesMy website provides a facility to upload images, using the ASP.NET FileUpload control. We accept both jpeg and tiff formats but I have just decided that all tiffs should be converted to jpegs at the time of upload. If possible, I want to avoid saving the original tiff to disk.
I would appreciate any sample coding suggestions for achieving this conversion prior to saving (ideally in VB.NET, though I could always run C# code through a converter).
i want to export an excel from my web application and want to save it on Web Server, but i am not able to save it on web server, i am able to do it on my local machine, but on web server it's not working.
View 1 Replieshow to download a file , from sql server 2005 to local disk.
using asp.net and c# as my code behind, when i click on gridview column, a pop up windows should appear asking fr the path to save in local disk, when name is entered and save button is clicked, that particular file should get saved in disk.
What is the best way to insert and retrieve images like :
In the database in binary form retrieve it with imagehandler, or
In the database by saving the path of the folder of the images and retrieve it, or
by saving the images directly to the folder and retrieve it...
I am using ASP.NET 3.5 with iTextSharp and I have the following code:
var templatePath = Server.MapPath(@"~/Templates/template1.pdf");
var newFilePath = Server.MapPath(@"~/TempFiles/new.pdf");
PdfReader pdfReader = new PdfReader(templatePath);
PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(newFilePath, FileMode.Create));
AcroFields pdfFormFields = pdfStamper.AcroFields;
pdfFormFields.SetField("Box1", "007");
pdfFormFields.SetField("Box2", "123456");
pdfStamper.FormFlattening = false;
pdfStamper.Close();
Response.ClearContent();
Response.Buffer = true;
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "attachment;filename=new.pdf"));
Response.WriteFile(newFilePath);
Response.End();
The above code fills out a pdf file and saves the new file to the TempFiles folder. It then prompts the user to either save or open the file. Can I achieve the same functionality without saving the file to the TempFiles location?
I have a file on the disk and I want to give Full Control Permission to all the users of that computer.
View 6 RepliesReally weird problem loading a file from disk:
string path = HttpContext.Current.Server.MapPath("~/Datasets/blob.xml");
FileStream stream = new FileStream(path, FileMode.Open);
Throws exception:An exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll but was not handled in user code
Additional information: Access to the path 'D:webrootafobDevv1.0.xAFOBDatasetslob.xml' is denied.
The strange thing is it was working 5 minutes ago. I checked permissions on the disk and both the Debugger and ASPNET have read/write rights as do I.
I need to be able to read an excel file from a file upload control but I can not save the file to disk first, it must be done in memory.
[Code]....
Above is my code for reading the data file if it IS saved to disk, but again, I have to be able to do this without saving the file to disk, it must be done in memory. I have not been able to find any sample code anywhere on how to do this from memory, everything seems to force the file be uploaded, saved to disk, and then read in the connection string, which again I can not do.
In my application I store a string as content of a HTML file.
How can I preview this content (assuming that it's modified from original content) in browser but not having to save it to disk locally.
And the preview to be in another tab or window.
I have a css file which I want to read from disk and in that content I want to find and replace all linebreaks (do I look for vbCrlf or ...?)
Public Shared Function GetFileContents(ByVal FullFilename As String) As String
Dim filecontents As String = ""
If File.Exists(FullFilename) Then
Dim objStreamReader As StreamReader
objStreamReader = File.OpenText(FullFilename)
filecontents = objStreamReader.ReadToEnd()
objStreamReader.Close()
End If
Return filecontents
End Function
So in the returned variable "filecontents" I want to find and replace any linebreaks.
FILE: style.css
#progress{color:#000;width:500px;height:30px;padding:0px;clear:both;}
#progress ul{list-style:none;padding:0px;margin: auto;display:block;}
#progress ul li{list-style:none;display:inline;float:left;width:auto;height:30px;padding:0px;line-height:30px; font-family:Arial, Helvetica, sans-serif; font-size:13px;}
I've a view which display all data. I'm using ViewData, for loop etc.. on the view, to show the data. It may sound weird, but is it possible to write view to disk as a file instead of showing in the browser. The reason is that, business wants functionality to send the same view file as email attachment to the user.
View 3 RepliesHow to save Ajax Editor content as an HTML file to a disk?
Let's say I have an Ajax Editor which allows user to type or paste in long message or writting. Once he clicks on "submit" button, an HTML file will be created and save to a disk. I am working on asp.net 3.5, ajax version 3.5 (from codeplex, work well).
I'm using ASP.NET for file uploads, and I'm hitting a bit of a snag in that data sent by the client as multipart form data is read straight into RAM.
Obviously, this means maximum file upload size is limited to the available RAM on the machine, and even then is much smaller as soon as you have multiple simultaneous uploads.
Is it possible to get ASP.NET to write the data to a temporary file on the hard drive as it is recieved rather than reading into RAM?
What are the options for handling file uploads to reduce the memory footprint? Is there a way to upload in chunks? Is there a way to stream upload directly to disk instead of loading entire file in server memory?
View 1 Repliesi need to save multiple documents stored in SQL server as Image type to disk.
What i want to do is "backup" all files in a table (column) to disk, zip them and Response.TransmitFile(FilePath) to client.
I could use C# ot VB but that would require a lot of connections to database or a lot of server memory and i don't want that, becauze there are a lot of files to be saved Since SQL can write files to disk i was thinking about saving those files to disk directly from sql. Something like when u're doing a backup
[Code]....
I want to save zipped file on server disk using DotNetZip in ASP.Net .... This code creates zip and download it in client side download folder..
ZipFile zip = new ZipFile();
List<Attachment> listattachments = email.Attachments;
int acount = attachments.Count;
for (int i = 0; i < acount; i++)
[Code] ....
I have an httpmodule and it has a handler for OnEndRequest. I am trying to write the HttpContext.Response.OutputStream to a file. I am trying to use the Read method of it. But when it is called the exception message i get is "Specified method is not supported". So i am not able to do what i want that is, write the response to a file on the disk. I am able to write the HttpContext.Request.InputStream to a file using its Read method which i do in a handler for OnBeginRequest.
View 2 Replieshow to add an attachement to an email from the fileupload without saving the document
to the server.
in my project i have a problem with sending document from local machine D Drive..
when i am click send button clicks it automatically fetch the document and send automatically ..
I am working on a journal website where user submit manuscripts , pdf files , is it good idea to store pdf files on directory or on database.
View 1 Replies