J
jawloc
Hi I have a question that I hope someone can help me with. I have
created a web page that allows a user to upload an image with a
caption to my web server. Here is what happens when the user loads
the page:
1 - A temporary folder is created with that user's username here is an
example of the folder "c:\wwwroot\upload\tmp\username".
2 - The user uploads the file it gets saved in the temp folder.
3 - The user hits the save button and the caption is dumped to the
database and then a new permanent folder is created (example "c:
\wwwroot\upload\article_43"). So now the file stored in the temp
folder gets copied to the permanent folder and then the content of the
temp folder is deleted along with the temp folder.
This is where I run into a problem. My temporary folder does not
delete immediately if at all. But it does not give me an error. If I
try to do anything with that folder from that point on I get an access
denied error. If I stop the IIS server the temp folder disappears and
everything is as it should be.
Either I'm not using the proper code to create or delete my files and
folders or its something to do with IIS or my web.config.
Here is my helper subs I use to create copy and delete.
================================================================
Public Sub CheckPath(ByVal Path As String)
Dim Mydirectory As New DirectoryInfo(Path)
If Not Mydirectory.Exists Then
Mydirectory.Create()
End If
End Sub
Public Sub CopyDir(ByVal FromPath As String, ByVal ToPath As
String)
Dim toDir As New DirectoryInfo(ToPath)
Dim fromDir As New DirectoryInfo(FromPath)
If toDir.Exists Then
toDir.Delete(True)
toDir.Create()
Else
toDir.Create()
End If
If fromDir.Exists Then
For Each theFiles As FileInfo In fromDir.GetFiles
Dim TargetFile As String = ToPath + "\" +
theFiles.Name
theFiles.CopyTo(TargetFile, True)
Next
End If
End Sub
Public Sub DelDir(ByVal DirPath As String)
Dim DelDir As New DirectoryInfo(DirPath)
If DelDir.Exists Then
DelDir.Delete(True)
End If
End Sub
Public Sub delFile(ByVal FullPath As String)
Dim TargetFile As New FileInfo(FullPath)
If TargetFile.Exists Then
TargetFile.Delete()
End If
End Sub
================================================================
Any help would be apreciated.
Thanks in advance
Eric
created a web page that allows a user to upload an image with a
caption to my web server. Here is what happens when the user loads
the page:
1 - A temporary folder is created with that user's username here is an
example of the folder "c:\wwwroot\upload\tmp\username".
2 - The user uploads the file it gets saved in the temp folder.
3 - The user hits the save button and the caption is dumped to the
database and then a new permanent folder is created (example "c:
\wwwroot\upload\article_43"). So now the file stored in the temp
folder gets copied to the permanent folder and then the content of the
temp folder is deleted along with the temp folder.
This is where I run into a problem. My temporary folder does not
delete immediately if at all. But it does not give me an error. If I
try to do anything with that folder from that point on I get an access
denied error. If I stop the IIS server the temp folder disappears and
everything is as it should be.
Either I'm not using the proper code to create or delete my files and
folders or its something to do with IIS or my web.config.
Here is my helper subs I use to create copy and delete.
================================================================
Public Sub CheckPath(ByVal Path As String)
Dim Mydirectory As New DirectoryInfo(Path)
If Not Mydirectory.Exists Then
Mydirectory.Create()
End If
End Sub
Public Sub CopyDir(ByVal FromPath As String, ByVal ToPath As
String)
Dim toDir As New DirectoryInfo(ToPath)
Dim fromDir As New DirectoryInfo(FromPath)
If toDir.Exists Then
toDir.Delete(True)
toDir.Create()
Else
toDir.Create()
End If
If fromDir.Exists Then
For Each theFiles As FileInfo In fromDir.GetFiles
Dim TargetFile As String = ToPath + "\" +
theFiles.Name
theFiles.CopyTo(TargetFile, True)
Next
End If
End Sub
Public Sub DelDir(ByVal DirPath As String)
Dim DelDir As New DirectoryInfo(DirPath)
If DelDir.Exists Then
DelDir.Delete(True)
End If
End Sub
Public Sub delFile(ByVal FullPath As String)
Dim TargetFile As New FileInfo(FullPath)
If TargetFile.Exists Then
TargetFile.Delete()
End If
End Sub
================================================================
Any help would be apreciated.
Thanks in advance
Eric