How to solve System.IO.File.Delete's permission error ?

when program execute System.IO.File.Delete(file)  

* file =  C:\WINDOWS\TEMP\tmp515.tmp   → I'm going to delete tmp515.tmp from Windows/temp

 I have no idea why it cause a error because the permission of access Windows\temp\  

have no idea why and how to start debug error  please help... thank you very much
 

0
jcjcjc
11/19/2007 12:11:13 PM
asp.net.getting-started 91979 articles. 2 followers. Follow

6 Replies
250 Views

Similar Articles

[PageSpeed] 32

 Make sure that ASPNET user have the permission for this if you are not using the impersonation.


Ravi |   Share Knowledge   |   Online messengers  
0
ravipahuja1
11/19/2007 12:51:42 PM

thank you

 can you explain more? I use Administrator login

where can I check if using impersonation? and how to  check if ASPNET user have permission for this requestion?

 

thank you again 

0
jcjcjc
11/19/2007 1:45:33 PM

Access to C:\WINDOWS folder and its subfolder is restricted unless you give permission to a specific user. Your ASP.NET user must have the requireed permissions.


Warm Regards

Aamir Mahmood(JSS)

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

If you have knowledge, let others light their candles in it. (Margaret Fuller)

0
AamirJS
11/19/2007 2:00:25 PM

I would also add that having your ASP.NET application accessing items in that folder doesn't sound like a great idea. For example, what if other sites are using the same temp folder? Should your application be able to delete those files too?

A better solution would be to use an isolated file storage area specifically for your application, or at least to include a temp folder in your application's root folder.

On top of that, if you are planning on hosting your site with a hosting company on a shared server you will not be able to access any sub-folder in C:\Windows and you won't be able to change the permissions.


Brent Jenkins
ASP.NET, C#, Web Developer
www.valewebdesign.co.uk
0
Brent
11/19/2007 2:27:00 PM

What are trying to do! if you want to clear the cache files this wont be the case for doing it!!

If you are trying to delete a file inside your application root folder, then you must be sure because ASP.NET runs under the ASPNET user account to give the right permissions ( windows 2000) if windows 2003 then u must give permissions to NETWORK SERVICE account.

HC


Haissam Abdul Malak
MCAD.NET
| Blog |
0
Haissam
11/19/2007 9:30:38 PM

I add ASP.NET and NETWORKSERVICE for permission of access the temp file

I can pass the code of System.IO.File.Delete but same error message happen on another code

in this code →  callback.DownloadFile(locFile); 

callback is a dll control  CIO.Framework.Remoting

this system use this .dll to do all most of things

I don't have the source code of CIO.Framework.Remoting , system works before have no idea why have permission problem suddenly ...

 

except check the temp file's permission , can you tell me where should I going to check if something wrong?

 

thank you 

0
jcjcjc
11/20/2007 1:34:36 AM
Reply:

Similar Artilces:

System.Net.Mail is giving error CS0029: Cannot implicitly convert type 'string' to 'System.Net.Mail.MailAddress'
I'm getting an error while trying to use the wizard to create a form and than pass it the vaibles to Mail. Any help would be much appreciated. SmtpClient smtpClient = new SmtpClient(); MailMessage message = new MailMessage(); try {   message.From = txtEmail.Text; message.To.Add("admin1@yoursite.com"); message.Subject = "Feedback"; message.CC.Add("admin1@yoursite.com"); message.CC.Add("admin2@yoursite.com"); message.IsBodyHtml = false; message.Body = txtMessage.Text; smtpClient.Send(message); lblStatus.Text = "Email successfully sent."; } catch (Exception ex) { lbl...

Why do I get this error: "Could not load file or assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot f
I downloaded a reputed sample project and cant get it started because I am getting this error: Error 2 Could not load file or assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. D:\bills system\Bills Desktop\test\Dashboard\src\Dashboard\web.config 46  What can I do?  You need to install AJAX extensions for asp.net 2.0. You can get it here:http://www.asp.net/ajax/ Which version of Visual Studio are you using? If you are not us...

How to empty/delete temp files in 'Microst.net\framework...'-directory because of error: 'Access Denied in ..directory
Hello, Within C# I made a web-app that displays and makes available for editing some data within a MS Access 2000 database. Everything works, editing, moving to next page and, you've guest it, move to previous page. Now hopfully a discription of a familiar situation: 1) I have a web-application made within C#; 2) Within the virtual root of my web-app I placed my .mdb(Access 2000 database). As a result of this I don't have any rights to the access-database; 3) I start my application, and edit a record and save it. Withing ie I can see my saved data! 4) I stop my application; ...

Error 25 Could not load file or assembly 'Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file s
Hi there,   I am just trying to learn AJAX at the moment and have run into a problem. I have copied over the example for cascading dropdowns and this is where I have the above error.The error occurs in the web.config file on this line <add assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>  Can anyone advise what I need to change? The sample is for old ajax version. you need to copy latest ASP.NET AJAX web.config to your projects web.config below is my cascading code for new version for you  ASPX &l...

Deleting a file with System.IO.File.Delete
Hi, how can I delete a File with System.IO.File.Delete after a Response.End What I'm doing -> I export a file and prompt the client to save it then I have to do a Resonse.End for the file to save. Afer that I want to be able to delete the file. I guess that after the Response.End I can't...... Any idea or tricks will be apreciated. Thank you. I think if have finished reading the file and sending it with Response.Write you can close file and remove it, before Response.End. Slava The point is that the file is streamed to the client when the processing o...

restoring the system's audio level and system's wave file audio level
Hello, I'm needing your help with "wizmo". With the volume= and wave= commands you can set the system's audio level and system's wave file audio level to a percentage of full volume. Is there a way to use "wizmo" to read the current system's audio level and current system's wave file audio level, then change these values via the commands mentioned above, and finally restore the previous read volume levels? If not, could the programmer please integrate such a function in "wizmo"? Or are there any other tools which can do tha...

Open file in browser or application getting the page's name as the file's name
Hi, I'm am trying to get a file to open in either a browser or application depending on the mime type. I'am using the following code in the page load. protected void Page_Load(object sender, EventArgs e){ if (!IsPostBack)    { DocumentInfo document = (DocumentInfo)Session["View_Document"]; StreamFile(document.Document, document.DocumentName, document.FileType.MimeType); } } }private void StreamFile(byte[] fileData, string originalFileName, string mimeType) { try { Response.Clear(); Response.ContentType = mimeType; Response.AddHeader("Con...

Unable to convert AJAX site in VS 2008, I get 'Could not load file or assembly 'System.Web.Extensions, Version=1.0.61025 error..'
This is the full message, i get one fore each ajax control on my site.  Error 1 Unable to create type 'cc1:TabContainer'. Could not load file or assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. V:\ASP\RemoteFitness3\Members\MembersHome.aspx 75  My web config is pointed to 3.5<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>   And i have...

Deleting a file using system.io.file.delete
Hi I'm trying to delete an uploaded file from a directory using the system.io.file.delete and I'm getting a URI formats are not supported error.The file uploads fine though.Here's the code..sAttachment = "Attachment.doc"System.IO.File.Delete("http://DevServ/XX/Attachments/" & sAttachmentAny help would be greatly appreciatedCheersLbob the methods in the system.io namespace use physical paths not virtual paths.Use server.mappath to convert from a virtual path to a physical path.System.IO.File.Delete(Server.MapPath("http://DevServ/XX/Attachments/" & sAttachment))Mike Banavige~~~~...

restoring the system's audio level and system's wave file audio level with "wizmo"
Hello, I'm needing your help with "wizmo". With the volume= and wave= commands you can set the system's audio level and system's wave file audio level to a percentage of full volume. Is there a way to use "wizmo" to read the current system's audio level and current system's wave file audio level, then change these values via the commands mentioned above, and finally restore the previous read volume levels? If not, could the programmer please integrate such a function in "wizmo"? Or are there any other tools which can do that? ...

How do I get around this error "Unable to cast object of type 'System.DBNull' to type 'System.String' "
I am using Visual Developer 2008 Express Edition for the first time, and I keep getting the following error below. The site allows anyone to enter with a valid username and password, but even when I logoff the site I get the same error....like the memory or database is not getting refreshed. I would think that when I initially compile the site that anything left in memory would be flushed out. Can someone please help me to figure this out. Thanks,Ramell P.S. The site is programmed using C#    Unable to cast object of type 'System.DBNull' to type 'System.String&...

DataAdapter can't create DataSet, error 'error the system cannot find the file specified'
Hello, As a relatively newby I'm creating a asp-aplication connected to my MS Access 2000 database. Everything worked perfectly until I, stupid enough I don't know which one, i deleted a file from my current project. When I want to create a DataGrid with updateble capabilities I encounter problems: 1) Create page; 2) Create database connection (odbc....); 3) Drag-drop my table from the connection-> connection & dataadapter are being generated; 4) Create Update query (insert & select are generated automaticly, update not because .net doen't know what the primary key ...

Javascript Problem i'm getting Error: [Exception... "'Permission denied to get property XULElement.selectedIndex' ....
Hi all,     I'm getting Error: [Exception... "'Permission denied to get property XULElement.selectedIndex' when calling method: [nsIAutoCompletePopup::selectedIndex]"  nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)". I have 2 text input field; userId, and userPassword and a login buttonboth input fields have added attribute onkeypress="return clickButton(event,'UserLogin_btnLogin')"and the login button have onclick="return buttonValidateLogin(event,'UserLogin_btnLogin', 'UserLogin_txtUserID', 'UserLogin_txtPassword')"What happens is that when i c...

File.delete() isnt deleting the file after it's downloaded....help please
hello , this is my code , I have the uploads in another folder , and to download i must move it to the website folder , but that's fine with me but what goes wrong is that the file must be deleted after the user downloads it , so it can be downloaded again , I am puttin file.delete() at the end of the code but it doesnt delete the file , wonder why ?!? using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.Web...

Web resources about - How to solve System.IO.File.Delete's permission error ? - asp.net.getting-started

Resources last updated: 1/6/2016 12:34:17 PM