By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,362 Members | 3,489 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,362 IT Pros & Developers. It's quick & easy.

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

P: n/a
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!

Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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...

Nov 21 '05 #2

P: n/a
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...
<cr********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
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...

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.