473,236 Members | 1,351 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,236 software developers and data experts.

getting "System.IO.IOException: The process cannot access the file" while delete a file

the following is the full page code for uploading a file to server.
since i got no idea to overwrite the file, i want delete the file if
the file is already uploaded.
i got the folder name and filename of the file to delete from the
so i got the above error when i try to delete the file before upload.
Please anyone help me to solve out from this error.

<%@ Import Namespace="System.IO" %>
<%@ Page Language="vb" %>
<Script Language="VB" RunAt="Server">
Dim MyPath, MyName as string

Sub Page_Load(Sender as Object, e as EventArgs)
dim serpath as string
MyPath = request.QueryString("path")
MyPath = replace(MyPath,"/","\")
MyPath = replace(MyPath,"""","")
serpath = server.MapPath("") ' Set the path.
MyPath = serpath & "\" & mypath
End Sub

Sub Upload_Click(Sender as Object, e as EventArgs)
' Display properties of the uploaded file
if File.exists(mypath) then
end if

' Let us recover only the file name from its fully qualified path at
Dim strFileName as string
strFileName = MyFile.PostedFile.FileName

' Let us Save uploaded file to server at
catch Exp as exception
response.Write("Error Occored")
End Try
myfile = nothing
End Sub
<table cellpadding="0" cellspacing="0" width="400" align="center">
<Font Color="DarkGreen" Face=Helvetica Size=3> <B>Upload your file
to replace the old file
<HR Size="2" Color=Black >
<Form Method="Post" EncType="Multipart/Form-Data" RunAt="Server">
Choose Your File To Upload : <BR>
<Input ID="MyFile" Type="File" RunAt="Server" Size="40"> <BR>
<Input Type="Submit" Value="Upload"
OnServerclick="Upload_Click" RunAt="Server">
<HR Size="2" Color=Black>


Jun 29 '06 #1
0 2796

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Earth Worm Jim | last post by:
I am using VS.Net 2003 on Windows 2003 Server (standard edition) and I am getting "The process cannot access the file because it is being used by another process" on DLL's in a VS.Net solution. ...
by: Brian Henry | last post by:
I want to list out a directory listing along with showing the file type name (like explorer does when it says something like "MyDoc.DOC - Microsoft Word Document" How do I get that file type name...
by: Alexandra | last post by:
Hi, I have a hidden system file that I need to read. I am logged in as an administrator. I can not change the file attributes using the windows explorer.
by: Clodoaldo Pinto Neto | last post by:
Hi all, I'm restoring a database from 7.3.4 FC1 to 7.4.2 FC2: $ pg_restore -d KakaoStats KakaoStats.dump pg_restore: could not execute query: ERROR: could not access file...
by: dejanvesic | last post by:
Hello. Windows service is in question, Framework 2.0, operating system is Windows XP Prof. Windows service is accessing file taking turns with ASP.NET application. For synhronisation of...
by: sharmin | last post by:
I have never used VB. Please help me for the following issues: 1. what software to use to make vb scripts? 2. where is a tutorial for beginners? 3. How to format an access file? I have to...
by: Daniel | last post by:
is there some per-process-limit on memory in .net processes? is there any way to increase it? i keep getting System.OutOfMemoryException when my box has 8 gigs of unused memory.
by: knuckels23 | last post by:
Hi All, I have a Random access file which is written using VB 6.0. I need to read this file using C#. The record used in VB to write the Random access file is as follows Type AA aa1 As...
by: passionateforjava | last post by:
Hi All, I am using struts application wherein I need to import file for some purpose.I have used input type="file" for the same which goes like: <input type="file" id="uploadFile" name="uploadFile"...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.