Click here to Skip to main content
15,893,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have something to do on network shared folder. But when I search on Internet, it giving me a code to do in own computer only. Step that I want to do is:

1. Check destination (network shared folder) path is empty or not.
2. Delete folder content (not the main one) eg: "\\USER-PC\File\"; the folder "File" no need to deleted, but the content inside is need to deleted.
3. Copy folder content from source to new destination.

No. 1 and 3 is coded. But No. 2 is not yet found. How to delete a directory on Network Shared Folder?

Delete directory code that I use but exception "The network path was not found.":
VB
My.Computer.FileSystem.DeleteDirectory(strDestination, FileIO.DeleteDirectoryOption.DeleteAllContents)



Please assist. TQ
Posted

1 solution

It sounds to me like you don't have delete directory permission to the folder. From the same machine, are you able to delete the folder manually. If you have permission to delete the contents manually, then you should be able to manually iterate through the files and then delete them.

e.g.

VB
Dim Files() As String = IO.Directory.GetFiles(ThePath)

For Each File In Files
    IO.File.Delete(File)
Next
 
Share this answer
 
Comments
Luiey Ichigo 3-Sep-14 22:13pm    
thanks man..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900