473,395 Members | 1,863 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,395 software developers and data experts.

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

hi,
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
request.QueryString("path")
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" %>
<html>
<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
File.Delete(mypath)
end if

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

' Let us Save uploaded file to server at
C:\ServerFolder\
Try
MyFile.PostedFile.SaveAs(MyPath)
catch Exp as exception
response.Write("Error Occored")
response.End()
End Try
myfile = nothing
End Sub
</Script>
<Body>
<table cellpadding="0" cellspacing="0" width="400" align="center">
<tr>
<td>
<Font Color="DarkGreen" Face=Helvetica Size=3> <B>Upload your file
to replace the old file
</Font>
<HR Size="2" Color=Black >
<P>
<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>
<BR>
<Input Type="Submit" Value="Upload"
OnServerclick="Upload_Click" RunAt="Server">
<P>
</Form>
<HR Size="2" Color=Black>
</td>
</tr>
</table>
</Body>
</html>

Thanks,
Mani

Jun 29 '06 #1
0 2815

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

Similar topics

4
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. ...
2
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...
13
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.
3
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...
0
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...
1
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...
4
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.
4
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...
6
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"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.