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

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

File is deleted but exception is thrown. How it is possible?

Posted By:      Posted Date: October 13, 2010    Points: 0   Category :ASP.Net

Hello everybody.

I am passing a file name via query string. When I am trying to delete the file it is throwing a FileNotFoundException. But the file practically deleted from the server. Both of the following codes of file delete :

File.Delete(Server.MapPath("~/Files/") + Request.QueryString["FileName"]);
File.Delete(Server.MapPath("~/Files/" + Request.QueryString["FileName"]));

are throwing that exception.

Can any one please tell me what is the reason behind this behavior or what I am doing wrong?

Thank you.

View Complete Post

More Related Resource Links

Exception thrown: database file cannot be found


I'm developing a desktop C# app that uses SQL Everywhere as an embedded database.
I generated strongly typed DataSet and use that to populate a DataGrid on my app.

When the app first loads, it populates the DataGrid with a line like this:


That all works fine. Later on, after adding more data to the database (through reading a csv file), I wanted to refresh the display on the DataGrid.

I used the same line of code:


Can not perform this operation.The file is no longer checked out or has been deleted?

In my sharepoint designer 2007, when I try to check in a file, it give me the following errors:

Can not perform this operation.The file is no longer checked out or has been deleted.

Please advise me how to fix this problem?


NullReference Exception when editing an xml file in C#

When trying to add new node to Category node, I get categoryNode is null, but it exists in xml file CODE: XmlDocument     xmlDoc = new XmlDocument(); xmlDoc.Load(requestPath);     XmlNode categoryNode = xmlDoc.SelectSingleNode("CATEGORY");     XmlNode newNode = xmlDoc.CreateElement("REQUEST");     XmlAttribute newAttribute = xmlDoc.CreateAttribute("description"); newAttribute.Value = request.GetId(); newNode.InnerText =   "blank"; newNode.Attributes.Append(newAttribute); categoryNode.AppendChild(newNode); xmlDoc.Save(requestPath);   FILE: <GROUP description="Kwang">   <CATEGORY description="soo">blank</CATEGORY>   </GROUP>

Exception of type 'System.ExecutionEngineException' was thrown.

Hi,       I am showing a WPF Window as ShowDialog().  Before loading the window, we are showing a message box. Upon Pressing Cancel Button from the Message box, Application throws "Exception of type 'System.ExecutionEngineException' was thrown.".. While cancelling, Events are raised to close the Window.. If we comment that code, window will be in the open state, other wise will "Throw the error". Please help me!!!!!!!!!  

Exception has been thrown by the target of an invocation.

hi!! i am new to this,please help me with this when i use this,,,,image.Source = new BitmapImage(new Uri(str, UriKind.RelativeOrAbsolute));  it is working but when i use array of images and use  image[0].Source = new BitmapImage(new Uri(str, UriKind.RelativeOrAbsolute)); it gives me error  Exception has been thrown by the target of an invocation.   thanks

File Not Found Exception from iiscore.dll

Create a asp.net mvc project with the default template  and used bmc appsight to monitor the w3wp process ; so when ever an action is clicked an exception is occured in iiscore.dll here is the sample one which i got.  Log Entry 530641OperationOpen "\\?\C:\CRAPPYTEST\HOME\ABOUT"CommentThe system cannot find the path specified. ProcessW3WP.exe:5436:5844Causality ID: {0B49C343-7918-4721-A53E-FFD4C7A1C35D}Moduleiiscore.dllTimeStart - Sep 14 18:39:43.913035Duration - 0.000121Stack Dumpiiscore.dll, 0x5d65fddciiscore.dll, 0x5d64b7b3iiscore.dll, 0x5d64fe97iiscore.dll, 0x5d65270fiiscore.dll, 0x5d6562dfiiscore.dll, 0x5d656338iiscore.dll, 0x5d65084eWEBENGINE.DLL, 0x5c8c289bWEBENGINE.DLL, 0x5c8c28d0System.Web.ni.dll, 0x1e7cdd3dSystem.Web.ni.dll, 0x1e7cdb80mscorwks.dll, 0x71761e6fmscorwks.dll, 0x719ba26emscorwks.dll, 0x718bdf6fmscorwks.dll, 0x719ba3a9mscorwks.dll, 0x718bef35mscorwks.dll, 0x719ba42dWEBENGINE.DLL, 0x5c8c7a2eWEBENGINE.DLL, 0x5c8c34cfmscorwks.dll, 0x718bea90mscorwks.dll, 0x718be3a2mscorwks.dll, 0x718be516mscorwks.dll, 0x718a1ec9kernel32.dll, 0x76881194ntdll.dll, 0x76f8b3f5ntdll.dll, 0x76f8b3c8

Filter out logically deleted data from dbf file using SSIS?

Hi Guys, while loading dbf file to sql server using SSIS,How can i filter out the records that are logically deleted in dbf file?    ~Technology Analyst~

Application Exception Rule Violation thrown on Delete

I basically have my first simple asp.net MVC 2.0 web application up and running except for deletes. I tried to do the first delete today, but it throws an exception with the text Rules Violation.  I'm not sure what is causing the error however.It shouldn't be the database (I don't think) because when I trace the database, I never see the delete call and after having it fail, I was able to sucessfully run:DELETE FROM [Work] WHERE work_id = 84 GOCurrently this is my method (yes its primitive, but I was just trying to get it working), its the db.SubmitChanges() line where the application exception gets thrown. [HttpPost] public ActionResult Delete(int id, FormCollection collection) { try { // TODO: Add delete logic here var result = db.Works.SingleOrDefault(w => w.work_id == id); if (result == null) return View("NotFound"); db.Works.DeleteOnSubmit(result); db.SubmitChanges(); return RedirectToAction("Index"); } catch { var result = db.Works.SingleOrDefault(w => w.work_id == id); return View(result); } } }This may be a Linq-to-Sql issue as this is really the first time I've us

Exception of type 'System.OutOfMemoryException' was thrown.

Hi, i am just using select stmt from some view. view defination is also selecting columns from inner join of 3 tables. view count is about 46 millions records. so while selecting from view it gives me: Exception of type 'System.OutOfMemoryException' was thrown. same error occur if i use direct select from those tables instead of select * from view. What is the reason behind this. Any help will be appreciated. Thanks Punia

need help about Exception of type 'System.Web.HttpUnhandledException' was thrown.

Hi Friends

I am developing a website in which i am using services of a third party service providers. after some transactions on their pages they are transfering control to my page say page1.aspx. 

But when the control is transfered to my page there is an exception /Runtime error..

I am unable to trace this error. I had tried to log all the errors. Where I found this error.

3/19/2010 3:34:44 AM
Offending URL: http://www.mydomain.com/ThankYou.aspx Source: System.Web Message: Exception of type 'System.Web.HttpUnhandledException' was thrown. Stack trace: at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.thankyou_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\5910a9b6\ab96f081\App_Web_upsitg7y.0.cs:line 0
at System.Web.HttpApplication.CallHandlerEx

Exception thrown when handling Window.Loaded event


Why is the exception assistant not "fired" in a debugging session when a Window.Loaded eventhandler calls code which throws an exception ?
        private void Window_Loaded(object sender, RoutedEventArgs e)
            //Application.Current.DispatcherUnhandledException +=
               new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Current_DispatcherUnhandledException);
            int a = 1;
            int b = 0;
            int c = a / b;

        void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)

Removing the comment signs (//) thus presenting an UnhandledException handler devinately makes the assistant "firing".
Is this behaviour by desi

Exception thrown from workflow



I got following exception in my workflow.

Type : System.Exception, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : #################(Exception Start)#####Transaction (Process ID 115) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.,
Workflow Manager,WFStart,0,
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.HasMoreRows()
   at System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout)
   at System.Workflow.Runtime.Hosting.PersistenceDBAccessor.RetrieveStateFromDB(DbCommand command, Boolean checkOwnership, Guid instanceId)
   at System.Workflow.Runtime.Hosting.PersistenceDBAccessor.RetrieveInstanceState(Guid instanceStateId, Guid ownerId, DateTim

TCP Client connecting to a dynamic ip - exception thrown


Im making a simple chat server for quite some time now and Im constantly having some easy problems I cant comprehend.

      client = new TcpClient();
      client.Connect(IPAddress.Parse(""), 15555);
It throws:
"A connection attempt failed because the connected party did not properly respond after a period of time, <br/>
or established connection failed because connected host has failed to respond"

Im connecting to myself over the internet I suppose but it wont work.

The thing is, Im not listening to this IP. Im listening to my LAN IP because Im connected to the internet through LAN so I cant listen to my global IP

because it throws an exception that the IP is not valid.

I suppose the real question is am I doing this right, and if not, what should i do?

sql server setup has encountered the following error exception has been thrown by the target of an i


OS - Windows Web Server 2008 R2

Processor: Intel (R) Xeon (R) CPU 5160 @ 3.00 GHZ 2.99 GHZ (2 Processor)

RAM 16.0 GB

System Type;: 64 bit Operating System

Trying to Install SQL Server 2008 R2 Standard

I installed all necessary SP and .Net Framework as instrcted but setup bring up the above error.

Please help - ASAP.


Content deployment job 'Remote import job for job with sourceID failed.The exception thrown was 'M


Anyone pls give me advice for Content Deployment at sharepoint 2007...

I am doing Content Deployment from one virtual machine to another virtual machine. Both virtual machines are at the different computers.

I got these errors..

Cannot create folder "Cache Profiles/_private". at Microsoft.SharePoint.Library.SPRequest.CreateFolderOnImport(String bstrUrl, String bstrFolderUrl, Guid guidFolderId, Int32 lDoclibRowId) at Microsoft.SharePoint.Deployment.FolderSerializer.CreateFolder(SerializationInfoHelper infoHelper, SPWeb parentWeb, ImportObjectManager objectManager) at Microsoft.SharePoint.Deployment.FolderSerializer.SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector) at Microsoft.SharePoint.Deployment.XmlFormatter.ParseObject(Type objectType, Boolean isChildObject) at Microsoft.SharePoint.Deployment.XmlFormatter.DeserializeObject(Type objectType, Boolean isChildObject, DeploymentObject envelope) at Microsoft.SharePoint.Deployment.XmlFormatter.Deserialize(Stream serializationStream) at Microsoft.SharePoint.Deployment.ObjectSerializer.Deserialize(Stream serializationStream) at Microsoft.SharePoint.Deployment.ImportObjectManager.ProcessObject(XmlReader xmlReader) at Microsoft.SharePoint.Deployment.SPImport.DeserializeObjects() at Microsoft.SharePoint.Deployment.SPImport.Run()


System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.


I get the following error anytime i change something in the XAML and try and build the project. If I change anything in the code behind it works everytime.... To get it to work i have to get out of the ide come back in place a space in one of the .vb files to change it then it will build..... Any ideas?


Error 107 The "ResourcesGenerator" task failed unexpectedly.
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at System.IO.MemoryStream.set_Capacity(Int32 value)
   at System.IO.MemoryStream.EnsureCapacity(Int32 value)
   at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.BinaryWriter.Write(Byte[] buffer, Int32 index, Int32 count)
   at System.Resources.ResourceWriter.WriteValue(ResourceTypeCode typeCode, Object value, BinaryWriter writer, IFormatter objFormatter)
   at System.Resources.ResourceWriter.Generate()
   at System.Resources.ResourceWriter.Dispose(Boolean disposing)
   at Microsoft.Build.Tasks.Windows.ResourcesGenerator.Execute()
   at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult) 

WCF - Works from console app, but not from IIS app. No exception being thrown.


Hi all.

We've been doing WCF apps for a while. Mostly web apps calling business objects/functionality in Windows Service hosted WCF Apps.

We recently ran into an issue, and have been banging our heads on it for a while.

The code works in Casini (VS2008's webserver), and from a test console app we wrote. But when we put the code in an aspx page, it just hangs.

No exception is being thrown.
When we remote debug the app, attaching VS2008 to the w3p process, we get an error pop box:

"An unhandled exception of type 'System.Configuration.ConfigurationErrorsException' occurred in mscorlib.dll

Additional information: This element is not currently associated with any context"

But it's not being caught by the try catch block.

We're using netTcpBinding (have tried pipe, but no luck as well)

The Service hosts multiple Contracts through different endpoints:


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