I am doing a very simple operation via c#.
1 I just copy an existing JPEG file in temp directory.
2 Then I open the copied Jpeg file from temp directory.
3 I try to delete the original Jpeg file and application crashes.
Please see below c# function for this:
public void DeleteAfterCopyingOriginalImageFile(string strOriginalJpeg)
string strTempFolder = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "JpegTemp");
DirectoryInfo directory = Directory.CreateDirectory(strTempFolder);
directory.Attributes = directory.Attributes | FileAttributes.Hidden;
string strTempJpeg = System.IO.Path.Combine(strTempFolder, "TempImage.jpg");
I need to follow exactly these steps (cannot delete original file before opening TempImage.jpg). Can anybody help in knowing why copy and opening of temp file lock the original file. How can I prevent original jpeg file from being locked. I am new in .Net. Please help me.
More Info about the user case: The user case is that user cannot perform any operation on original file. So a temporary copy of original file is created in temp folder. User can then open/edit temp file. And if he thinks that he can replace original file with that of edited (copied in temp directory) one or he does not need original file any more, he can delete original file (and if required, can make temp file as the original one). So I strictly need to follow the same steps.
Thanks in Advance