.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

SmtpClient and Locked File Attachments

Posted By: Amit Mehra     Posted Date: March 23, 2010    Points: 2   Category :ASP.Net
Got a note a couple of days ago from a client using one of my generic routines that wraps SmtpClient. Apparently whenever a file has been attached to a message and emailed with SmtpClient the file remains locked after the message has been sent. Oddly this particular issue hasn't cropped up before for me although these routines are in use in a number of applications I've built.

View Complete Post

More Related Resource Links

File Attachments from info-path forms to Sharepoint document library


Hi Experts,

How to upload file attachements from info-path forms to Sharepoint document library?

I need to add attachement from local-PC/Any User to Sharepoint Document Library.


Any help please?? Appreciated




Impossible to download .sdf file. Locked ?



I have installed a tiny test site derived from template LinkDirectory. It is working fine online, but I just cannot download the .sdf file.

When I try, using Filezilla, here is what I get :

Commande : RETR LinkDirectory.sdf
Réponse : 550 The process cannot access the file because it is being used by another process.

Commande : RETR LinkDirectory.sdf

Réponse : 550 The process cannot access the file because it is being used by another process.

How can I unlock this situation.

Thanks in advance.


Cannot save Configuration File ["ConfigurationSection properties cannot be edited when locked."]


I have the following code Segment

public Form1()
	Configuration MyConfig;
	ExeConfigurationFileMap MyMap = new ExeConfigurationFileMap();

	MyMap.LocalUserConfigFilename = Application.UserAppDataPath + @"\" + Application.ProductName + ".xml";
	MyMap.RoamingUserConfigFilename = Application.LocalUserAppDataPath + @"\" + Application.ProductName + ".xml"; ;
	MyMap.ExeConfigFilename = Application.CommonAppDataPath + @"\" + Application.ProductName + ".xml"; ;

//	MyConfig = ConfigurationManager.OpenMappedExeConfiguration(MyMap, System.Configuration.ConfigurationUserLevel.None );
	MyConfig = ConfigurationManager.OpenMappedExeConfiguration(MyMap, System.Configuration.ConfigurationUserLevel.PerUserRoaming);
//	MyConfig = ConfigurationManager.OpenMappedExeConfiguration(MyMap, System.Configuration.ConfigurationUserLevel.PerUserRoamingAndLocal );

	MyConfig.AppSettings.Settings.Add("Now", DateTime.Now.ToString() );


I am running for the 1st Time and trying to create the initial Config file.

I get an exception "ConfigurationSection properties cannot be edited when locked." on the MyConfig.Save() method.  This happens with the OpenMappedExeConfiguration( ...PerUserRoaming ...PerUser

Cotent Deployment - Problem with locked file


I'm trying to deploy the content from one server to another using the built-in "content deployment job".

Interminently, I receive the following error during the "Exporting" phase:

Content deployment job 'xyz' failed.The exception thrown was 'System.IO.IOException' : 'The process cannot access the file '00003682.dat' because it is being used by another process.'

The .dat file name is not always the same...

I am the only user connected / accessing the computer and there is enough space available on the C and D drives and .

Is there a logical cause to this problem.


Server error: is checked out or locked for editing by ... but page does not exist


I tried to rename a page in the source variation of a Publishing Site using Site Content and Structure tool, let's call it "newpage". This threw an HTTP 500 error. I then tried to rename it in SharePoint Designer. I got two message prompts, the first said:

"A file with the name Pages/newpage.aspx already exists. Do you want to replace this file?"

There is no file of that name in the Pages list in either the source or target variation. I said "Yes" and got the following error:

"Server error: The file <path>/newpage.aspx is checked out or locked for editing by ."

No user name was given in the message. I can successfully rename the page in the target variation to have the new name.

I also cannot create a new page in the source variation called newpage.aspx, I get an error saying that there is already a page of that name ... but there isn't. I have cleared the site and site collection recycle bins.

spfile.delete gives file is checked out or locked for editing exception.


hello friends,

i have developed a custom webservice wherein i try to move the spfile within a document library between two folders. I tried with spfile.delete but it gives me exception.

System.Runtime.InteropServices.COMException (0x8107090E): The file is a user http://tsnt4-test/espis/Lists/TSAkJKDocuments/154545445-342423/abc.doc DMTSIT \ spospisilova checked out or locked for editing.

even when i try to use spfile.copyTo and spfile.moveTo it gives me the same exception

i used the following two approaches

  //Approach 1

Having trouble cropping an image (w3wp.exe has the file locked).


Hey Guys,

Hoping someone can help im having a real issue with resaving an image (after I get the crop area from a jquery control). I get a GDI error and when I run handle.exe on the file it is open with the w3wp.exe.

I have 2 methods (1 that saves images when they have been uploaded and one that is meant to open and resave the image with new dimensions [for cropping]).

        protected void btnCrop_Click(object sender, EventArgs e)
            string profilePicFilePath = Server.MapPath("~/AppWide/User/Profile_Pics/" + userForPage.ProfilePicFilePath + "_temp" + ".jpg");

            //1) Load up image into memory
            Bitmap tempImage = new Bitmap(profilePicFilePath);

            Rectangle r = new Rectangle(Int32.Parse(x.Value), Int32.Parse(y.Value), Int32.Parse(w.Value), Int32.Parse(h.Value));

            System.Drawing.Image permImageToSave = cropImage(tempImage, r);

            //2) Resize image in memory using co-ordinates from boxes

            permImageToSave.Save(profilePicFilePath, ImageFormat.Jpeg);

            //3) Save the new image over the top of the old image

        //only allows uploading of .bmp, .jpg and .gif
        protected void ccMediaUploader_FileUploaded(object sender, UploaderEventArgs args)

            //first get th

SmtpClient attachment file size limit in .Net 4.0?


I am having trouble sending any file over about 3MB as an attachment using the SmtpClient class. I have no problems with smaller files. I get an index out of range error. I founf a reference on another site that said it supposed to be a known bug with the framework 4.0. I tried to change the target framework for my dll that actually sends the email back to 2.0, but is called from a 4.0 framework website, but that did not fix it.

Does anyone know if this is a known issue and how do you find out if/when it is fixed or if there is a patch available?






Transferring files to the Sharepoint sites - Error file is locked




I'm trying to migrate my files from my file server to Sharepoint. However, it kept saying thta the files are in used and locked. However there's nobody accessing the files.


Is there any way for us to do a force moving of files into Sharepoint?

File Splitter in .Net

I love to do utility programs in .Net. And this is one of them. As I was playing with JSplit (a free file splitter program), I wondered if I could do it in .Net. The framework supports file operations like reading files in bytes and creating them. It is indeed easy to do file operations in .Net Basics on File operations

Upload Multiple File using JQuery in asp.net

In this article I have explained how to upload multiple files using file upload control. I have used jQuery plugin for uploading multiple files.

I have also explained how to check for file type, file maximum size limit using jQuery & also using server side validation code.

Creating Excel file from C#

I used below coding for create a excel sheet.I got from on web site.
In below coding there is no problem.Its create the excel file.If i run second time,its ask to overwrite the current excel file.If I said "Yes" then it ok ,but If I select cancel button,its generate the Error message.The exception is

Upload a File to a SharePoint Document Library - Part I

The following helper class demonstrates a few techniques that allow documents to be uploaded to a SharePoint document library programmatically without using the API or a custom web service. You don't need to specify a document library name, and it will create any folders specified in the URL as required. File meta data will be updated if any properties are passed.

How to call an .exe file in .net

Sometimes a developer has to call an EXE from another EXE. While calling EXE there can be a requirement to pass parameter.

ClientAccessPolicy file in SharePoint 2010

I am upgrading my Silverlight demo code from the old beta to beta 2 and see that there are a few new considerations for the deployment of ClientAccessPolicy.xml files. In a previous post I demonstrated how to do this for SharePoint 2007. The heartburn that I get with that approach is any site collection owner or designer can drag the file into the site collection and open the site up to unwanted client access issues. In 2010 the virtual path provider no longer serves the files from the root of the site collection

Multi File Upload Using JQuery!

Everyone knows about the file upload in .NET. But the multi file upload is some what difficult in .NET. For that purpose we can have some AJAX or JQuery!. Jquery is the latest advanced version. It will give some animated upload. You can try it for your own!!!!

Transfering a file from Conputer to PDA

You can transfer one file at a time between your computer and another Bluetooth device by using the Bluetooth File Transfer Wizard. For example, you can transfer files between your computer and a mobile phone or a PDA. You can also transfer files between two computers that use Bluetooth.
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