Help: I can't delete a file on a mapped network drive using vb.net!

C

createdbyx

I am trying to make a file sync utillity to sync files between my
laptop and my desktop pc. On my desktop machine (xp pro sp2) I have
shared my "Visual Studio Projects" folder using windows simple file
sharing. And have specified the "Allow network users to change my
files." option as well.

Then on my laptop (xp home sp2) I have mapped a network drive using
windows explorer. So on my laptop I have a Y: drive that points to the
"Visual Studio Projects" folder on my desktop pc.

Here is the test code I am trying to use on my laptop ...

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
Dim file As String
file = "Y:\Visual Studio Projects\Axiom\Axiom.sln"
If IO.File.Exists(file) Then IO.File.Delete(file)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Me.Close()
End Sub

I have made sure that the files I am trying to delete are not read only
and are not being used by another process. But I keep getting a
System.UnauthorizedAccessException being thrown. I have searched
extensivly on the net but have not been able to get a streight answer.
I have also tried using FileIOPermission code from examples I have
found but still can't delete the file(s) on the mapped drive. I have
also tried using the .NET framework tools to give full trust to the
assembly but to no avail.

I should also say that I can delete files from the local machine
(laptop) just fine. For example if I specify

file = "c:\error.txt"

the test app works just fine. I only get a
System.UnauthorizedAccessException when I try to delete a file over a
mapped network drive. Seeing as how the file is on another computer I
am thinking it has to do with "Local Intranet" rules. But when I
trusted the assembly using .net framework tools I specified Full trust
for both "My Computer" and "Local Intranet".

I can also Create/Rename/Read/Write/ and delete files on Y: drive using
windows explorer without any problems.

So what do I need to do, or what code do I need to write to allow my
application to delete a file on a mapped network drive. I'm at my wits
end! I'm beggining to think .NET Framework is being a little to secure!
 
C

createdbyx

Correction what I meant to say was "I can't delete files on Y: drive
using
windows explorer either"

So how can I give permission to windows explorer to delete a file on a
mapped network drive...
 
T

Terry Olsen

Sounds like a rights issue. You will need to go to the computer that the Y:
drive is mapped to, and set the security as such that you can delete the
files. Usually, you add your domain ID and give it "Full Control". Or, add
"Everyone" and give that group Full Control....if everyone is trusted that
is...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top