Click here to Skip to main content
16,004,901 members
Home / Discussions / C#
   

C#

 
AnswerRe: Deploying custom fonts at Client Place Pin
Paddy Boyd23-Apr-09 6:34
Paddy Boyd23-Apr-09 6:34 
GeneralRe: Deploying custom fonts at Client Place Pin
ramz_g23-Apr-09 7:53
ramz_g23-Apr-09 7:53 
QuestionC# and Outlook Pin
thehacker21323-Apr-09 2:53
thehacker21323-Apr-09 2:53 
Question[Message Deleted] Pin
DJ24523-Apr-09 2:21
DJ24523-Apr-09 2:21 
AnswerRe: Create GanttChart Pin
musefan23-Apr-09 2:45
musefan23-Apr-09 2:45 
AnswerRe: Create GanttChart Pin
paas23-Apr-09 3:12
paas23-Apr-09 3:12 
AnswerRe: Create GanttChart Pin
Christian Graus23-Apr-09 10:23
protectorChristian Graus23-Apr-09 10:23 
QuestionHttpPostedFileBase and locking... Pin
daviiie23-Apr-09 2:17
daviiie23-Apr-09 2:17 
Hi all,

Ok this is the problem. I am using the microsoft MVC web framework to build a web app. I have a method that uploads files to the server by retriving the HttpPostedFileBase files from the HttpFileCollectionBase in the Request. I then invoke the HttpPostedFileBase method SaveAs(path) to save those files to the filesystem.

I have just implemented a Remove method that takes the filename and path, ensures the existence of the file by calling File.Exists() then attempting to call File.Delete() to remove the said file. The problem is when I have just uploaded this file, when I go then to delete it right away I get a

"The process cannot access the file 'C:\....\file.jpg' because it is being used by another process."

Now I suspect that that HttpPostedFileBase method SaveAs() has locked that file and not released it. But I am not 100% sure. My only other suspision is that the actual page view method goes and does a:

DirectoryInfo info = new DirectoryInfo(imagesPath.ToString());
FileInfo[] files = info.GetFiles();

In order to retrieve all the files located in that directory. One of the two of these is locking that file. I am more inclined to believe its the SaveAs() method as the remove works intermittently and if it were the page view I'd expect it not to work ever.

Does anyone know anything about this, I have been googling away like mad trying to find out how to get HttpPostedFileBase to release the file its just saved with no avail.

Cheers.
AnswerRe: HttpPostedFileBase and locking... Pin
DEVOXE25-Oct-11 22:11
DEVOXE25-Oct-11 22:11 
QuestionHow to open a file Pin
NarVish23-Apr-09 2:05
NarVish23-Apr-09 2:05 
AnswerRe: How to open a file Pin
OriginalGriff23-Apr-09 2:17
mveOriginalGriff23-Apr-09 2:17 
GeneralRe: How to open a file Pin
NarVish23-Apr-09 2:24
NarVish23-Apr-09 2:24 
GeneralRe: How to open a file Pin
Mirko198023-Apr-09 2:29
Mirko198023-Apr-09 2:29 
GeneralRe: How to open a file Pin
Eddy Vluggen23-Apr-09 2:30
professionalEddy Vluggen23-Apr-09 2:30 
GeneralRe: How to open a file Pin
OriginalGriff23-Apr-09 2:41
mveOriginalGriff23-Apr-09 2:41 
GeneralRe: How to open a file Pin
NarVish23-Apr-09 2:57
NarVish23-Apr-09 2:57 
QuestionGetting Fileinfo and fileattributes in one read operation ? Pin
fracalifa23-Apr-09 1:41
fracalifa23-Apr-09 1:41 
QuestionShow the progress bar while executing a batch file in C# windows forms? [modified] Pin
Nitin Jenekar23-Apr-09 1:40
Nitin Jenekar23-Apr-09 1:40 
AnswerRe: How to show the progress bar while executing a batch file in C# windows forms? Pin
DaveyM6923-Apr-09 1:48
professionalDaveyM6923-Apr-09 1:48 
GeneralRe: How to show the progress bar while executing a batch file in C# windows forms? Pin
Nitin Jenekar28-Apr-09 2:45
Nitin Jenekar28-Apr-09 2:45 
GeneralRe: How to show the progress bar while executing a batch file in C# windows forms? Pin
DaveyM6928-Apr-09 4:05
professionalDaveyM6928-Apr-09 4:05 
GeneralRe: How to show the progress bar while executing a batch file in C# windows forms? Pin
Nitin Jenekar7-May-09 3:19
Nitin Jenekar7-May-09 3:19 
AnswerRe: How to show the progress bar while executing a batch file in C# windows forms? Pin
Rob Philpott23-Apr-09 1:54
Rob Philpott23-Apr-09 1:54 
GeneralRe: How to show the progress bar while executing a batch file in C# windows forms? Pin
MumbleB23-Apr-09 2:13
MumbleB23-Apr-09 2:13 
GeneralRe: How to show the progress bar while executing a batch file in C# windows forms? Pin
Marc A. Brown23-Apr-09 2:29
Marc A. Brown23-Apr-09 2:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.